:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --text: #1c1e21;
  --muted: #646a70;
  --border: #e2e1db;
  --accent: #c4570b;          /* Buttons: 4,6:1 mit weißer Schrift */
  --accent-hover: #a94a08;
  --accent-text: #ffffff;
  --link: #b0500a;
  --ring: rgba(196, 87, 11, .35);
  --danger: #b93a2e;
  --warn-bg: #fdecea;
  --tag-bg: #edece7;
  --ok: #1d7a4c;
  --ok-bg: #e3f3ea;
  --loan: #1f68a8;
  --loan-bg: #e6f0fa;
  --away: #6a4bb6;
  --away-bg: #efe9fb;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 15, .05), 0 1px 3px rgba(20, 20, 15, .07);
  --shadow-md: 0 6px 18px rgba(20, 20, 15, .09), 0 2px 4px rgba(20, 20, 15, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --surface: #1e2023;
    --surface-2: #26292d;
    --text: #e8e8e5;
    --muted: #9ea3a8;
    --border: #33363b;
    --accent: #f08a3c;
    --accent-hover: #f5a062;
    --accent-text: #17181a;
    --link: #f5a062;
    --ring: rgba(240, 138, 60, .45);
    --danger: #ef7a6d;
    --warn-bg: #3b2320;
    --tag-bg: #2c2f33;
    --ok: #6fcf9b;
    --ok-bg: #1a3328;
    --loan: #82bbee;
    --loan-bg: #1b2c3d;
    --away: #b9a4f4;
    --away-bg: #2a2342;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  /* Namen enthalten weiche Trennstriche (Filter „trenn“); hart umbrechen nur im Notfall */
  overflow-wrap: break-word;
}
a { color: var(--link); text-underline-offset: .15em; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.85rem); line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; letter-spacing: -.01em; margin: 1.5rem 0 .5rem; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .tile, .icon-btn { transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s; }
}
.muted { color: var(--muted); font-weight: normal; }

/* Kopfzeile */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem;
  padding: .6rem 1rem; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
@media (max-width: 480px) {
  .topbar { padding: .5rem .6rem; }
  .topbar nav a { padding: .3rem .55rem; font-size: .92rem; }
}
.topbar nav a {
  text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 999px; white-space: nowrap;
}
.topbar nav a.active { background: var(--tag-bg); color: var(--text); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* Meldungen */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); }
.flash.error { border-left-color: var(--danger); background: var(--warn-bg); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  padding: .55rem 1rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
  min-height: 2.6rem;
}
.btn { font-weight: 500; box-shadow: var(--shadow-sm); }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost.danger:hover { background: var(--warn-bg); border-color: transparent; }
.btn.small { padding: .3rem .6rem; min-height: 2rem; font-size: .9rem; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; }
.actions form { margin: 0; }

/* Eingaben */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .65rem; width: 100%;
  min-height: 2.6rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox] { width: auto; min-height: 0; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters input[type=search] { flex: 2 1 260px; }
.filters select { flex: 1 1 170px; width: auto; min-width: 0; }
.filters .reset { font-size: .9rem; }

.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.inline-form input { flex: 2 1 200px; width: auto; }
.inline-form select { flex: 1 1 180px; width: auto; }
.inline-form.small { margin: .75rem 0; }

.form { display: grid; gap: .9rem; max-width: 720px; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; align-content: start; }
.form label small { font-weight: normal; }
.form .row { display: grid; gap: .9rem; grid-template-columns: 1fr 1fr; }
.form .row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) {
  .form .row, .form .row.three { grid-template-columns: 1fr; }
}
label.check { display: flex; align-items: center; gap: .5rem; font-weight: normal; }
.new-location { border: 1px dashed var(--accent); border-radius: var(--radius); padding: .5rem .9rem .9rem; margin: 0; }
.new-location[hidden] { display: none; }
.new-location legend { font-size: .85rem; color: var(--accent); padding: 0 .3rem; }
.photo-preview { max-width: 200px; max-height: 200px; border-radius: var(--radius); border: 1px solid var(--border); }
.photo-preview[hidden] { display: none; }
.current-photo { display: flex; align-items: center; gap: 1rem; }
.current-photo img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius); }

/* Startseite: Kategorie wählen */
.cat-tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile { display: flex; align-items: center; justify-content: space-between; gap: .75rem; height: 100%;
  min-height: 4.5rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius-lg); text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm); }
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.tile strong { font-size: 1.1rem; min-width: 0; }
.tile .count { flex: none; }
.tile.all { border-left-color: var(--border); background: transparent; box-shadow: none; }
@media (max-width: 480px) {
  .cat-tiles { grid-template-columns: 1fr; gap: .45rem; }
  .tile { min-height: 3.4rem; }
}

/* Material-Karten */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.card {
  display: flex; gap: .8rem; padding: .6rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none; color: var(--text); height: 100%;
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.thumb { flex: 0 0 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--tag-bg);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.thumb:has(img) { background: #fff; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: .3rem .6rem; font-size: .85rem; color: var(--muted); margin-top: auto; }
.cards.compact .thumb { flex-basis: 48px; height: 48px; font-size: 1.3rem; }
.tag { background: var(--tag-bg); border-radius: 999px; padding: 0 .55rem; font-size: .8rem; color: var(--text); }
.tag.warn { background: var(--warn-bg); color: var(--danger); }

.empty { text-align: center; padding: 2.5rem 1rem; background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius); }

/* Detailseiten */
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .75rem; }
.detail { display: grid; gap: 1.5rem; grid-template-columns: minmax(220px, 340px) 1fr auto; align-items: start; }
.detail.loc { grid-template-columns: 1fr auto; }
.photo img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.no-photo { aspect-ratio: 1; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 3rem; color: var(--muted); }
.no-photo small { font-size: .85rem; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem .9rem; margin-top: 1rem; }
.qr-box { background: #fff; padding: .75rem; border-radius: var(--radius); border: 1px solid var(--border);
  width: 170px; text-align: center; }
.qr-box img { width: 100%; display: block; }
.qr-box small { color: #555; font-size: .7rem; overflow-wrap: anywhere; }
@media (max-width: 860px) {
  .detail, .detail.loc { grid-template-columns: 1fr; }
  .qr-box { justify-self: start; }
}
.gallery { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery li { position: relative; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: var(--radius); border: 1px solid var(--border); }
.gallery form { position: absolute; top: .3rem; right: .3rem; margin: 0; }
.gallery .del { width: 1.9rem; height: 1.9rem; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: .9rem; line-height: 1; }
.gallery .del:hover { background: var(--danger); }
.photo-upload { margin: .75rem 0 0; }
.photo-upload input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; min-height: 0; padding: 0; }
.photo-upload label { position: relative; }
details.edit { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
details.edit summary { cursor: pointer; color: var(--muted); }
details.edit .form { margin: 1rem 0; }

/* Orte-Baum */
.tree { list-style: none; margin: 0; padding: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.tree li { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .55rem .9rem .55rem calc(.9rem + var(--depth, 0) * 1.5rem); border-bottom: 1px solid var(--border); }
.tree li:last-child { border-bottom: 0; }
.tree a { text-decoration: none; color: var(--text); }
.tree a:hover { color: var(--accent); }
.count { background: var(--tag-bg); border-radius: 999px; padding: 0 .6rem; font-size: .85rem;
  color: var(--muted); text-decoration: none; min-width: 2rem; text-align: center; }

/* Kategorien */
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; max-width: 640px; }
.cat-list li { display: flex; align-items: center; gap: .6rem; }
.cat-list .rename { display: flex; gap: .4rem; flex: 1; margin: 0; }
.cat-list form { margin: 0; }

/* Etiketten */
.labels-select section { margin-bottom: 1.5rem; }
.labels-select label.check { padding: .3rem 0 .3rem calc(var(--depth, 0) * 1.5rem); }
.actions.sticky { position: sticky; top: 3.2rem; background: var(--bg); padding: .5rem 0; margin: 0; z-index: 5; }
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, 64mm); gap: 3mm; }
.label {
  width: 64mm; height: 30mm; display: flex; align-items: center; gap: 2.5mm; padding: 2mm;
  border: 1px dashed #999; background: #fff; color: #000; break-inside: avoid; overflow: hidden;
}
.label img { width: 25mm; height: 25mm; flex: none; }
.label div { display: flex; flex-direction: column; min-width: 0; }
.label strong { font-size: 11pt; line-height: 1.15; }
.label small { font-size: 8pt; color: #444; margin-top: 1mm; }

@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .label-sheet { gap: 2mm; }
}

/* Bausteine */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.25rem; }
.panel-title, .panel-subtitle { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 1rem; }
.panel-subtitle { margin: 1.5rem 0 .5rem; }
.icon-btn { width: 2rem; height: 2rem; flex: none; border-radius: 999px; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-size: .85rem; }
.icon-btn:hover { background: var(--warn-bg); color: var(--danger); }

/* Material-Detailseite: links der Artikel, rechts abgesetzt die Ausleihe.
   2×2-Raster, damit die Karten jeder Zeile oben und unten bündig abschließen. */
.item { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem;
  grid-template-areas: "head loan" "facts qr"; }
.item-main, .item-side { display: contents; }
.item-head { grid-area: head; }
.loan-panel { grid-area: loan; align-content: start; }
.item-facts { grid-area: facts; }
.qr-card { grid-area: qr; }

.item-head { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 1.5rem; align-items: start; }
.item-photo img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block;
  background: #fff; border-radius: var(--radius); }
.item-photo .no-photo { border-radius: var(--radius); background: var(--surface-2); border: 0; }
.item-title { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.item-title h1 { margin: 0; }
.eyebrow { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--link); text-decoration: none; }
.subtitle { margin: 0; color: var(--muted); font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.chips .tag { font-size: .85rem; padding: .1rem .65rem; }
.item-title .actions { margin: .75rem 0 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: .8rem; color: var(--muted); margin-bottom: .1rem; }
.facts dd { margin: 0; font-weight: 500; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95em; }
.item-facts .notes { margin: 0; background: var(--surface-2); border: 0; }

.tag.status-available { background: var(--ok-bg); color: var(--ok); }
.tag.status-out, .tag.loan { background: var(--loan-bg); color: var(--loan); }
.tag.status-away, .tag.away { background: var(--away-bg); color: var(--away); }
.tag.status-overdue { background: var(--warn-bg); color: var(--danger); }

/* Ausleih-Panel: eigene Farbfläche, Statusfarbe als Akzent */
.loan-panel { --state: var(--ok); --state-bg: var(--ok-bg);
  background: linear-gradient(180deg, var(--state-bg), var(--surface) 9rem);
  border: 1px solid color-mix(in srgb, var(--state) 30%, var(--border));
  border-top: 4px solid var(--state); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 1.1rem 1.25rem 1.25rem; display: grid; gap: 1rem; }
.loan-panel.is-out { --state: var(--loan); --state-bg: var(--loan-bg); }
.loan-panel.is-away { --state: var(--away); --state-bg: var(--away-bg); }
.loan-panel.is-overdue { --state: var(--danger); --state-bg: var(--warn-bg); }
.loan-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.loan-head h2 { margin: 0; font-size: 1.1rem; }
.pill { background: var(--state); color: var(--surface); border-radius: 999px; padding: .15rem .7rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.borrower { display: flex; align-items: center; gap: .8rem; }
.borrower-label { display: block; font-size: .8rem; color: var(--muted); }
.borrower strong { font-size: 1.2rem; line-height: 1.2; }
.avatar { width: 2.8rem; height: 2.8rem; flex: none; border-radius: 999px; display: grid; place-items: center;
  background: var(--state, var(--loan)); color: var(--surface); font-weight: 700; font-size: 1.15rem; }
.loan-dates { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 0; }
.loan-dates div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .7rem; }
.loan-dates dt { font-size: .75rem; color: var(--muted); }
.loan-dates dd { margin: 0; font-weight: 600; }
.loan-hint { margin: 0; font-weight: 600; color: var(--state); }
.loan-note { margin: 0; padding: .55rem .75rem; border-radius: var(--radius); background: var(--surface-2);
  font-size: .95rem; white-space: pre-wrap; }
.loan-panel form { margin: 0; }
.loan-form { gap: .75rem; }
.loan-form .row { grid-template-columns: 1fr 1fr; gap: .6rem; }
.loan-history { border-top: 1px solid var(--border); padding-top: .75rem; }
.loan-history summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: .5rem;
  min-height: 2rem; list-style: none; }
.loan-history summary::-webkit-details-marker { display: none; }
.loan-history summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.loan-history[open] summary::after { content: "▴"; }
.timeline { list-style: none; margin: .5rem 0 0 .35rem; padding: 0 0 0 1rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; display: flex; justify-content: space-between; align-items: flex-start;
  gap: .5rem; padding: .35rem 0 .35rem .25rem; }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: .75rem; width: 10px; height: 10px;
  border-radius: 999px; background: var(--surface); border: 2px solid var(--muted); }
.timeline li > div { display: flex; flex-direction: column; min-width: 0; font-size: .95rem; }
.timeline .muted { font-size: .85rem; }

.qr-card { display: flex; flex-direction: column; align-items: center; gap: .9rem; text-align: center; }
.qr-card .panel-title { align-self: stretch; text-align: left; margin: 0; }
.qr-card img { width: 140px; height: 140px; background: #fff; border-radius: 8px; padding: 6px; display: block;
  margin: auto 0; }
.qr-text { display: flex; flex-direction: column; align-items: stretch; gap: .6rem; align-self: stretch; }
.qr-card small { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  /* Handy/Tablet: eine Spalte, Ausleihe direkt unter dem Artikelkopf –
     nach dem QR-Scan das Wichtigste */
  .item { grid-template-columns: minmax(0, 1fr); gap: 1rem;
    grid-template-areas: "head" "loan" "facts" "qr"; }
  .qr-card { display: grid; grid-template-columns: 96px 1fr; text-align: left; align-items: center; }
  .qr-card .panel-title { grid-column: 1 / -1; }
  .qr-card img { width: 96px; height: 96px; padding: 4px; margin: 0; }
}
@media (max-width: 560px) {
  .panel { padding: 1rem; }
  .item-head { grid-template-columns: 1fr; gap: 1rem; }
  .item-photo img, .item-photo .no-photo { aspect-ratio: 4 / 3; }
  .item-title .actions .btn { flex: 1 1 auto; }
}

/* Übersicht „Verliehen“ */
.loan-list { list-style: none; margin: 0; padding: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.loan-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.loan-list li:last-child { border-bottom: 0; }
.loan-list li.overdue { box-shadow: inset 4px 0 0 var(--danger); }
.loan-list form { margin: 0; flex: none; }
.loan-tool { display: flex; gap: .8rem; align-items: center; text-decoration: none; color: var(--text); min-width: 0; }
.loan-tool .thumb { flex-basis: 48px; height: 48px; font-size: 1.3rem; }
.loan-tool:hover strong { color: var(--link); }
.overdue-text { color: var(--danger); }

/* Ausleihe: Person & Adresse */
.borrower-name { display: block; font-size: 1.2rem; font-weight: 700; line-height: 1.2; color: var(--text); }
a.borrower-name { text-decoration: none; }
a.borrower-name:hover { color: var(--link); text-decoration: underline; }
.form .row.zip-city { grid-template-columns: 6.5rem 1fr; }
.form .row.street-no { grid-template-columns: 1fr 6.5rem; }
.id-capture { display: grid; gap: .3rem; }
.file-btn, .form label.file-btn { position: relative; overflow: hidden; display: inline-flex; font-weight: 500; font-size: 1rem; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; }

/* Personen */
.person-list li { padding: .5rem 1rem; }
.person-row { display: flex; align-items: center; gap: .75rem; min-width: 0; text-decoration: none; color: var(--text); }
.person-row:hover strong { color: var(--link); }
.person-meta { display: flex; align-items: center; gap: .4rem; flex: none; }
.avatar.small { width: 2.2rem; height: 2.2rem; font-size: .95rem; }
.avatar.large { width: 3.5rem; height: 3.5rem; font-size: 1.5rem; }
.person { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem;
  grid-template-areas: "head id" "loans id" "edit edit"; }
.person-head { grid-area: head; display: flex; gap: 1rem; align-items: center; }
.person-head h1 { margin: 0 0 .25rem; }
.person-head address { font-style: normal; color: var(--muted); }
.id-card { grid-area: id; display: flex; flex-direction: column; gap: .75rem; }
.id-card .panel-title, .person-loans .panel-title { margin: 0; }
.id-card .actions { margin: auto 0 0; }
.id-image { width: 100%; max-height: 420px; object-fit: contain; display: block;
  border-radius: var(--radius); background: var(--surface-2); }
.id-locked { margin: 0; padding: 1rem; border-radius: var(--radius); background: var(--surface-2); }
.person-loans { grid-area: loans; display: grid; gap: .75rem; align-content: start; }
.person-loans .timeline { margin-top: 0; }
.person-edit { grid-area: edit; margin: 0; padding-top: 1rem; }
.person-edit .form { margin: 1rem 0; }
@media (max-width: 760px) {
  .person { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "id" "loans" "edit"; gap: 1rem; }
}

/* Ausleihformular: Verleihen | Selbst mitnehmen */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); }
.form .segmented label { display: block; font-weight: 600; font-size: .9rem; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 2.4rem; padding: .3rem .4rem;
  white-space: nowrap; font-size: .88rem;
  border-radius: calc(var(--radius) - 3px); color: var(--muted); cursor: pointer; text-align: center; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--ring); }
.loan-form .only-self { display: none; }
.loan-form.is-self .only-loan, .loan-form:has(input[value=self]:checked) .only-loan { display: none; }
.loan-form.is-self .only-self, .loan-form:has(input[value=self]:checked) .only-self { display: inline; }
.loan-form div.only-loan { display: grid; gap: .5rem; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.form .field-head label { font-weight: 600; font-size: .92rem; }
.field-head .link { font-size: .9rem; font-weight: 600; padding: .25rem 0; min-height: 2rem; }
.person-summary { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .45rem .7rem;
  border-radius: var(--radius); background: var(--ok-bg); color: var(--ok); font-size: .9rem; font-weight: 600; }
.person-summary[hidden] { display: none; }
.person-summary .link { margin-left: auto; color: var(--link); font-size: .85rem; }

/* Dialog (auf dem Handy als Blatt von unten) */
dialog.sheet { border: 0; padding: 0; width: min(440px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
dialog.sheet::backdrop { background: rgba(10, 10, 10, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-body { display: grid; gap: 1rem; padding: 1.1rem 1.25rem 1.25rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
.sheet-foot { display: flex; justify-content: flex-end; gap: .5rem; }
.sheet-error { margin: 0; padding: .5rem .75rem; border-radius: var(--radius); background: var(--warn-bg);
  color: var(--danger); font-weight: 600; font-size: .9rem; }
.sheet-error[hidden] { display: none; }
@media (max-width: 560px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom); }
  .sheet-foot .btn { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: sheet-in .2s ease-out; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(16px); } }
}
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover { border-color: var(--border); background: transparent; }
.delete-blocked { display: grid; gap: .5rem; justify-items: start; }
.delete-blocked p { margin: 0; padding: .55rem .75rem; border-radius: var(--radius); background: var(--warn-bg);
  color: var(--danger); font-size: .92rem; }

/* Konto-Link in der Kopfzeile */
.account-link { margin-left: auto; display: flex; align-items: center; gap: .45rem; text-decoration: none;
  color: var(--muted); padding: .2rem .55rem .2rem .25rem; border-radius: 999px; }
.account-link:hover, .account-link.active { background: var(--tag-bg); color: var(--text); }
.account-link .avatar { --state: var(--accent); color: var(--accent-text); }
@media (max-width: 760px) {
  /* Handy: Inventar-Name und Konto in der ersten Zeile, Navigation darunter */
  .account-name { display: none; }
  .topbar .brand { order: 1; }
  .account-link { order: 2; }
  .topbar nav { order: 3; flex-basis: 100%; }
}

/* Anmelden, Einrichten, Einladung */
.auth-page main.auth { max-width: 440px; margin: 0 auto; padding: clamp(1.5rem, 6vh, 4rem) 1rem 2rem; }
.auth-brand { font-weight: 700; font-size: 1.3rem; text-align: center; margin-bottom: 1.25rem; }
.auth-card { display: grid; gap: 1rem; padding: 1.5rem; }
.auth-card h1 { margin: 0; font-size: 1.5rem; }
.auth-card p { margin: 0; }
.auth-hint { font-size: .9rem; text-align: center; }

/* Konto */
/* zwei Spalten, die sich jeweils lückenlos von oben füllen (keine Zeilen über beide Spalten) */
.account { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.account-col { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.col-title { margin: 0 0 -.25rem; font-size: 1rem; color: var(--muted); font-weight: 600; }
.account .panel { padding: 1.1rem 1.25rem; }
.account .form { gap: .75rem; }
@media (max-width: 860px) { .account { grid-template-columns: minmax(0, 1fr); } }
.account .panel-title { margin-bottom: .75rem; }
.small { font-size: .88rem; }
.member-list, .invite-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.member-list li { display: flex; align-items: center; gap: .6rem; }
.invite-list li { display: grid; gap: .5rem; padding: .75rem; border-radius: var(--radius); background: var(--surface-2); }
.invite-list li > div:first-child { display: grid; gap: .2rem; min-width: 0; }
.invite-link { font-size: .8rem; min-height: 2.2rem; color: var(--muted); }
.invite-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.invite-actions form { margin: 0; }

/* Passkeys */
.passkeys.welcome { border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 3px var(--ring), var(--shadow-sm); }
.passkeys p { margin: 0 0 .75rem; }
.passkey-list { margin-bottom: .75rem; }
.passkey-list .grow { flex: 1; display: grid; min-width: 0; }
.passkey-list form { margin: 0; }
.passkey-actions { display: grid; gap: .5rem; justify-items: start; }
.passkey-login { display: grid; gap: .75rem; }
.passkey-login[hidden] { display: none; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Für Nachbarn sichtbar: Schalter */
.tag.shared { background: var(--ok-bg); color: var(--ok); }
.switch-row { display: flex; align-items: center; gap: .75rem; cursor: pointer; text-align: left;
  font: inherit; color: var(--text); background: none; border: 0; padding: .25rem 0; }
.form label.switch-row { display: flex; font-weight: normal; }
.switch-row > span:last-child { display: grid; gap: .15rem; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.switch { position: relative; flex: none; width: 2.75rem; height: 1.6rem; border-radius: 999px;
  background: var(--border); transition: background-color .15s; }
.switch::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.2rem; height: 1.2rem;
  border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch-row input:checked + .switch, .switch-row[aria-checked="true"] .switch { background: var(--ok); }
.switch-row input:checked + .switch::after, .switch-row[aria-checked="true"] .switch::after { transform: translateX(1.15rem); }
.switch-row input:focus-visible + .switch, .switch-row:focus-visible .switch { outline: 3px solid var(--ring); outline-offset: 2px; }
.switch-row:focus-visible { outline: none; }
.share-toggle { margin: .5rem 0 0; }
.share-toggle .switch-row { font-size: .95rem; font-weight: 500; }

/* Nachbarschaft */
.lead { margin: -.25rem 0 1rem; }
.filter-check { white-space: nowrap; font-size: .95rem; }
.neighbor-item { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: stretch; }
.neighbor-item .item-head, .neighbor-item .owner-card { grid-area: auto; }
.owner-card { display: grid; gap: .75rem; align-content: start; }
.owner-card .panel-title { margin: 0; }
.owner-name { margin: 0; font-size: 1.15rem; font-weight: 700; }
@media (max-width: 900px) { .neighbor-item { grid-template-columns: minmax(0, 1fr); } }

/* Anfragen */
.badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .72rem; font-weight: 700;
  margin-left: .2rem; vertical-align: 1px; }
.request-list { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .75rem; }
.request { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem 1rem; align-items: center; padding: .9rem 1rem; }
.request.is-open { border-left: 4px solid var(--loan); }
.request-msg { grid-column: 1 / -1; margin: 0; padding: .5rem .75rem; border-radius: var(--radius);
  background: var(--surface-2); font-size: .95rem; }
.request-msg.answer { background: transparent; border: 1px dashed var(--border); }
.request-actions { grid-column: 1 / -1; display: grid; gap: .5rem; margin: 0; }
.request-actions .actions { margin: 0; }
.incoming-request { display: grid; gap: .5rem; padding: .75rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--loan) 40%, var(--border)); }
.incoming-request p { margin: 0; }
.request-card { display: grid; gap: .75rem; align-content: start; }
.request-card .panel-title { margin: 0; }
.request-state { margin: 0; padding: .6rem .8rem; border-radius: var(--radius); background: var(--loan-bg); color: var(--loan); font-weight: 600; }
.request-state.ok { background: var(--ok-bg); color: var(--ok); }
.request-state.no { background: var(--warn-bg); color: var(--danger); }
.neighbor-main, .neighbor-side { display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
details.hint { font-size: .9rem; }
details.hint summary { cursor: pointer; color: var(--link); }
details.hint ol { margin: .5rem 0 0; padding-left: 1.2rem; display: grid; gap: .3rem; }
details.hint code { font-size: .85em; background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; overflow-wrap: anywhere; }

/* Foto aus dem Internet */
.photo-web { border: 1px dashed var(--border); border-radius: var(--radius); padding: .5rem .9rem .9rem; margin: 0;
  display: grid; gap: .6rem; justify-items: start; }
.photo-web legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.photo-web label { justify-self: stretch; }
.photo-source { display: block; margin-top: .35rem; font-size: .75rem; color: var(--muted); text-align: center; }
.photo-source a { color: inherit; }
