:root {
  --loden: #2f4b3e;
  --loden-d: #22362d;
  --loden-l: #e3ebe5;
  --messing: #a8801f;
  --messing-l: #f1e8cc;
  --papier: #f3f5f1;
  --weiss: #ffffff;
  --tinte: #1c2621;
  --grau: #5a665e;
  --linie: #d7dcd4;
  --rot: #8c2d38;
  --rot-l: #f6e4e6;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font: 16px/1.45 var(--sans);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--messing); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--loden); color: #fff;
  padding: max(.55rem, env(safe-area-inset-top)) max(.9rem, env(safe-area-inset-right)) .8rem max(.9rem, env(safe-area-inset-left));
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; max-width: 900px; margin: 0 auto; }
.brand h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: .01em; line-height: 1.15; }
.brand p { margin: 0; font-size: .82rem; color: #cfdcd3; }
.top-actions { display: flex; gap: .35rem; }
.ic {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: inherit;
}
.top .ic:hover { background: rgba(255, 255, 255, .12); }
.ic.dark { color: var(--tinte); }
.ic.dark:hover { background: var(--papier); }
.search {
  display: flex; align-items: center; gap: .55rem;
  max-width: 900px; margin: .3rem auto 0;
  background: #fff; color: var(--grau); border-radius: 12px; padding: 0 .8rem;
}
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--tinte);
  font-size: 1.05rem; padding: .75rem 0; outline: none;
}
.search:focus-within { outline: 3px solid var(--messing); }
.search input::-webkit-search-cancel-button { height: 18px; width: 18px; }

.net {
  background: var(--messing-l); color: #5a4408; text-align: center;
  font-size: .85rem; padding: .35rem .8rem;
}

main { max-width: 900px; margin: 0 auto; padding-bottom: 4rem; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: .8rem .9rem .2rem; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px;
  border: 1px solid var(--linie); border-radius: 999px; background: #fff;
  padding: .3rem .9rem; font-size: .92rem;
}
.chip[aria-pressed="true"], .opt input:checked + span {
  background: var(--loden); border-color: var(--loden); color: #fff;
}
.opt { display: inline-block; position: relative; }
.opt span {
  display: inline-block; min-height: 38px; padding: .42rem .9rem;
  border: 1px solid var(--linie); border-radius: 999px; background: #fff; font-size: .92rem; cursor: pointer;
}
.vh { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt input:focus-visible + span { outline: 3px solid var(--messing); outline-offset: 2px; }

/* ---------- Trefferzeile ---------- */
.meta {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .6rem .9rem; color: var(--grau); font-size: .88rem;
}
.meta-r { display: flex; gap: .4rem; align-items: center; }
.meta select, .btn.small {
  min-height: 38px; border: 1px solid var(--linie); border-radius: 10px; background: #fff; padding: .25rem .6rem; font-size: .9rem; color: var(--tinte);
}
.badge {
  display: inline-block; min-width: 1.35rem; margin-left: .4rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--messing); color: #fff; font-size: .78rem; line-height: 1.35rem; text-align: center;
}

/* ---------- Liste ---------- */
.list { list-style: none; margin: 0; padding: 0; background: #fff; border-top: 1px solid var(--linie); }
.list li { border-bottom: 1px solid var(--linie); }
.row {
  display: grid; grid-template-columns: 4.3rem 1fr auto; gap: .75rem; align-items: start;
  width: 100%; text-align: left; border: 0; background: transparent; padding: .8rem .9rem;
}
.row:hover, .row:active { background: var(--loden-l); }
.nr { display: flex; flex-direction: column; align-items: flex-start; padding-right: .5rem; border-right: 2px solid var(--messing); min-height: 2.6rem; }
.nr b { font-family: var(--serif); font-size: 1.3rem; line-height: 1.15; color: var(--loden); font-variant-numeric: lining-nums; }
.nr small { font-size: .7rem; color: var(--grau); line-height: 1.2; max-width: 100%; hyphens: auto; overflow-wrap: break-word; }
.nr.leer { border-right-color: var(--linie); justify-content: center; }
.txt { min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.titel { font-weight: 600; font-size: 1.04rem; line-height: 1.3; overflow-wrap: anywhere; }
.pers { color: var(--grau); font-size: .9rem; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.tag { font-size: .76rem; padding: .05rem .5rem; border-radius: 999px; background: var(--papier); border: 1px solid var(--linie); color: var(--grau); }
.stat { font-size: .74rem; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--linie); color: var(--grau); white-space: nowrap; }
.stat.digital { background: var(--messing-l); border-color: #dcc98e; color: #5a4408; }
.stat.beides { background: var(--loden-l); border-color: #b9cbbf; color: var(--loden-d); }

.state { text-align: center; padding: 2.5rem 1.5rem; color: var(--grau); }
.state h2 { color: var(--tinte); font-size: 1.2rem; margin-bottom: .4rem; }
.state p { margin: .3rem 0 1rem; }
.state code { background: #fff; border: 1px solid var(--linie); padding: .05rem .35rem; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.05rem; border-radius: 11px;
  border: 1px solid var(--linie); background: #fff; color: var(--tinte); text-decoration: none; font-weight: 500;
}
.btn.primary { background: var(--loden); border-color: var(--loden); color: #fff; }
.btn.primary:hover { background: var(--loden-d); }
.btn.danger { color: var(--rot); border-color: #dfb8be; }
.btn.grow { flex: 1; }
.btn.small { min-height: 38px; padding: .25rem .8rem; font-size: .9rem; font-weight: 400; }

/* ---------- Sheets ---------- */
dialog {
  border: 0; padding: 0; background: #fff; color: var(--tinte);
  width: 100%; max-width: 640px; max-height: 94dvh; margin: auto auto 0;
  border-radius: 18px 18px 0 0; overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(22, 32, 27, .55); }
@media (min-width: 700px) {
  dialog { margin: auto; border-radius: 14px; max-height: 88dvh; }
}
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; margin: 0; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem .6rem .55rem 1rem; border-bottom: 1px solid var(--linie);
}
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { padding: 1rem; overflow: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot {
  display: flex; flex-wrap: wrap; gap: .5rem;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--linie); background: #fff;
}

/* Detailansicht */
.d-titel { font-size: 1.6rem; line-height: 1.2; overflow-wrap: anywhere; }
.d-pers { margin: .35rem 0 0; color: var(--grau); }
.standort {
  display: flex; align-items: center; gap: 1rem; margin: 1.1rem 0 0;
  padding: .9rem 1rem; border-radius: 12px; background: var(--loden-l); border-left: 5px solid var(--messing);
}
.standort .big { font-family: var(--serif); font-size: 2.3rem; font-weight: 700; line-height: 1; color: var(--loden-d); font-variant-numeric: lining-nums; }
.standort .desc { font-size: .95rem; }
.standort .desc b { display: block; font-size: 1.05rem; }
.digi { margin: .8rem 0 0; padding: .9rem 1rem; border-radius: 12px; background: var(--messing-l); }
.digi p { margin: 0 0 .5rem; font-size: .9rem; color: #5a4408; }
.digi code { display: block; word-break: break-all; padding: .5rem .6rem; background: #fff; border-radius: 8px; margin-bottom: .6rem; font-size: .9rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; align-items: baseline; margin: 1.1rem 0 0; }
.facts dt { color: var(--grau); font-size: .9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.d-note { margin: 1rem 0 0; padding: .7rem .8rem; background: var(--papier); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-meta { margin: 1rem 0 0; font-size: .8rem; color: var(--grau); }

/* Formulare */
.fld { display: block; margin: .9rem 0 0; font-size: .86rem; color: var(--grau); }
.fld input, .fld select, .fld textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .62rem .7rem;
  border: 1px solid #c5ccc3; border-radius: 10px; background: #fff; font-size: 1rem; color: var(--tinte);
}
.fld textarea { min-height: 5.5rem; resize: vertical; }
.fld.big textarea { min-height: 8rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.grp { margin: 1rem 0 0; padding: 0; border: 0; min-width: 0; }
.grp > legend { padding: 0; font-size: .86rem; color: var(--grau); margin-bottom: .35rem; }
.opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.hint { margin: .35rem 0 0; font-size: .85rem; color: var(--grau); }
.hint button, .linkbtn { border: 0; background: none; color: var(--loden); text-decoration: underline; padding: 0 .15rem; font-size: inherit; }
.warn { margin: .5rem 0 0; padding: .55rem .75rem; border-radius: 10px; background: var(--messing-l); color: #5a4408; font-size: .88rem; }
.warn.err { background: var(--rot-l); color: var(--rot); }
.taginput { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .25rem; padding: .35rem; border: 1px solid #c5ccc3; border-radius: 10px; background: #fff; }
.taginput input { flex: 1; min-width: 7rem; border: 0; padding: .35rem; font-size: 1rem; outline: none; }
.taginput .tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .88rem; padding: .15rem .3rem .15rem .6rem; background: var(--loden-l); border-color: #b9cbbf; color: var(--loden-d); }
.taginput .tag button { border: 0; background: none; font-size: 1.05rem; line-height: 1; padding: .1rem .3rem; color: inherit; }
.section { margin: 1.3rem 0 0; padding-top: 1rem; border-top: 1px solid var(--linie); font-family: var(--serif); font-size: 1.05rem; }
.help { font-size: .88rem; color: var(--grau); margin: .4rem 0 0; }
.filter-group { margin: 0 0 1.2rem; }
.filter-group h3 { font-family: var(--sans); font-size: .95rem; font-weight: 600; margin-bottom: .5rem; }
.sum { margin: .8rem 0 0; padding: .8rem 1rem; background: var(--papier); border-radius: 10px; font-size: .92rem; }
.sum ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.menu-list { display: flex; flex-direction: column; padding: .4rem 0; }
.menu-list button {
  text-align: left; border: 0; background: none; padding: .85rem 1.1rem; font-size: 1.02rem; min-height: 48px;
}
.menu-list button:hover { background: var(--papier); }
.menu-list button.danger { color: var(--rot); }
.menu-info { padding: .6rem 1.1rem 0; font-size: .88rem; color: var(--grau); }
.menu-info code { word-break: break-all; }

/* Hinweis-Toast */
.toast {
  position: fixed; top: auto; right: auto; margin: 0; border: 0; overflow: visible;
  left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); z-index: 50;
  transform: translateX(-50%); pointer-events: none; width: max-content;
  max-width: min(92vw, 30rem); padding: .7rem 1.1rem; border-radius: 12px;
  background: var(--tinte); color: #fff; font-size: .95rem;
}
.toast.err { background: var(--rot); }

@media (max-width: 380px) { .row { grid-template-columns: 3.9rem 1fr; } .stat { grid-column: 2; justify-self: start; } .nr b { font-size: 1.15rem; } }
