/* Mobile-first: Basis = Handy, Erweiterungen per min-width. Nichts wird abgeschnitten – Werte umbrechen. */
:root {
  --good: #2e7d32;
  --warn: #b26a00;
  --star-off: #c9ccd1;
  --star-on: #f5a623;
  --gap: .75rem;
}
@media (prefers-color-scheme: dark) {
  :root { --good: #81c784; --warn: #ffb74d; --star-off: #4a4f57; }
}

html { -webkit-text-size-adjust: 100%; }
body { overflow-wrap: anywhere; }
main.container, header.container { padding-left: 12px; padding-right: 12px; }
img { max-width: 100%; }

/* Navigation */
header nav { flex-wrap: wrap; gap: .25rem 0; }
header nav ul { flex-wrap: wrap; margin: 0; }
header nav ul:first-child { width: 100%; }
header nav li { padding: .35rem .5rem; }
.brand { font-weight: 700; text-decoration: none; }
.hide-mobile { display: none; }

form.inline { display: inline; margin: 0; }
button.small, a.small[role=button] { padding: .3rem .65rem; font-size: .85rem; width: auto; margin: 0; }
.small { font-size: .85rem; }
.muted { color: var(--pico-muted-color); }
.error { color: var(--pico-del-color); }
.success { color: var(--good); }
h2 { font-size: 1.35rem; }

.login { max-width: 420px; margin: 2rem auto; }

.toolbar { display: flex; flex-direction: column; gap: .25rem; margin-bottom: var(--gap); }
.toolbar h2 { margin: 0; }
.sort, .tabs { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .9rem; }
.sort a[aria-current], .tabs a[aria-current] { font-weight: 700; text-decoration: underline; }

/* Karten */
.grid-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.card { padding: 0; margin: 0; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.card-img { position: relative; aspect-ratio: 16 / 10; background: var(--pico-secondary-background); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-placeholder { display: grid; place-items: center; height: 100%; font-size: 2.5rem; opacity: .5; }
.score { position: absolute; top: .5rem; right: .5rem; background: var(--pico-primary-background); color: var(--pico-primary-inverse);
  border-radius: 999px; padding: .15rem .6rem; font-weight: 700; font-size: .9rem; }
.card-body { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.card-body h3 { font-size: 1.05rem; margin: 0; }
.card-body h3 a { text-decoration: none; }
.card-body p { margin: 0; }
.meta { font-size: .8rem; color: var(--pico-muted-color); display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: center; }
.price { font-size: 1.25rem; font-weight: 700; }

/* Eckdaten: eine Spalte auf dem Handy, Werte dürfen umbrechen */
.facts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: .25rem 0; font-size: .9rem; }
.facts div { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .2rem 0;
  border-bottom: 1px dotted var(--pico-muted-border-color); min-width: 0; }
.facts dt { color: var(--pico-muted-color); font-weight: normal; margin: 0; flex: none; }
.facts dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }

.sources { display: flex; flex-wrap: wrap; gap: .35rem; }
.source { font-size: .8rem; padding: .15rem .55rem; border: 1px solid var(--pico-primary-border); border-radius: 999px; text-decoration: none; }
.source.offline { opacity: .6; text-decoration: line-through; border-style: dashed; }

.badge { display: inline-block; font-size: .75rem; padding: .1rem .45rem; border-radius: .3rem; line-height: 1.4;
  background: var(--pico-secondary-background); color: var(--pico-secondary-inverse); }
.badge.good { background: var(--good); color: #fff; }
.badge.warn { background: var(--warn); color: #fff; }
.flags { display: flex; flex-wrap: wrap; gap: .3rem; }

/* Bewertungen */
.ratings { display: flex; flex-direction: column; gap: .15rem; }
.rating-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rater { font-size: .8rem; color: var(--pico-muted-color); min-width: 4.5rem; }
/* Klickbare (eigene) und reine Anzeige-Sterne (Partnerin) müssen identisch aussehen:
   Pico gibt Buttons eigene Schrift, Höhe und Abstände – deshalb alles explizit festlegen. */
.stars { display: inline-flex; align-items: center; gap: .15rem; }
.star, button.star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; padding: 0; margin: 0;
  font: inherit; font-size: 1.3rem; line-height: 1; color: var(--star-off);
  background: none; border: none; border-radius: .25rem; box-shadow: none;
}
.star.on, button.star.on { color: var(--star-on); }
button.star { cursor: pointer; }
button.star:hover { transform: scale(1.15); }
button.star:focus-visible { outline: 2px solid var(--pico-primary); outline-offset: 1px; }
.stars:not(.editable) { opacity: .9; }

.hide-form summary { font-size: .85rem; color: var(--pico-muted-color); }
.hide-form form { display: grid; gap: .4rem; margin-top: .4rem; }
.hide-form select, .hide-form input, .hide-form button { margin: 0; font-size: .9rem; }

/* Listen (ausgeblendete Objekte, Termine, Makler) */
.collapsible { margin-top: 2rem; }
.collapsible > summary h3 { display: inline; font-size: 1.1rem; }
.rows { list-style: none; padding: 0; margin: 0; }
.row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: .6rem; align-items: start; padding: .7rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.row > .row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
.thumb { width: 64px; height: 48px; border-radius: .3rem; overflow: hidden; display: grid; place-items: center;
  background: var(--pico-secondary-background); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-main { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.row-main .badge { align-self: flex-start; }

/* Tabellen werden auf dem Handy zu Blöcken */
.stack-table { width: 100%; }
.stack-table thead { display: none; }
.stack-table tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.stack-table td { display: block; padding: .1rem 0; border: none; }
.stack-table td[data-label]::before { content: attr(data-label) ": "; color: var(--pico-muted-color); font-size: .85rem; }

.gemeinde-list { display: grid; gap: .5rem; }
.gemeinde { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: center;
  padding: .4rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.gemeinde label { margin: 0; font-size: .85rem; display: flex; gap: .3rem; align-items: center; }
.gemeinde input[type=checkbox] { margin: 0; }

.detail-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.detail-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: .3rem; }
.description { white-space: pre-line; font-size: .9rem; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.stat { padding: .5rem; border: 1px solid var(--pico-muted-border-color); border-radius: .4rem; }
.stat strong { display: block; font-size: 1.2rem; }

/* ab Tablet */
@media (min-width: 640px) {
  main.container, header.container { padding-left: 16px; padding-right: 16px; }
  header nav ul:first-child { width: auto; }
  .hide-mobile { display: inline; }
  .toolbar { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratings { flex-direction: row; flex-wrap: wrap; gap: .15rem 1rem; }
  .row { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .row > .row-actions { grid-column: auto; flex-direction: column; align-items: flex-end; }
  .thumb { width: 80px; height: 60px; }
  .detail-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ab Desktop */
@media (min-width: 1024px) {
  .grid-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stack-table thead { display: table-header-group; }
  .stack-table tr { display: table-row; }
  .stack-table td { display: table-cell; padding: .4rem .5rem; border-bottom: 1px solid var(--pico-muted-border-color); }
  .stack-table td[data-label]::before { content: none; }
}

/* Detailseite & Formulare */
.source-row { display: flex; flex-direction: column; gap: .2rem; padding: .6rem 0; border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.source-row form { margin-top: .2rem; }
.star-radio { display: inline-flex; align-items: center; gap: .2rem; margin-right: .6rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.tag-list label { font-size: .9rem; margin: 0; }
.note-preview { white-space: pre-line; background: var(--pico-secondary-background); color: var(--pico-secondary-inverse); padding: .35rem .5rem; border-radius: .3rem; }
.suggestion { display: flex; flex-direction: column; gap: .3rem; padding: .6rem 0; border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.suggestion form { display: flex; gap: .4rem; flex-wrap: wrap; }
details.broker { border-bottom: 1px solid var(--pico-muted-border-color); padding: .5rem 0; }
details.broker summary { overflow-wrap: anywhere; }
.detail header h2 { margin-bottom: .25rem; }
.empty { text-align: left; }

/* Ortsteile in den Einstellungen */
.gemeinde .ortsteile { grid-column: 1 / -1; margin: .2rem 0 0; }
.gemeinde .ortsteile summary { color: var(--pico-primary); }
.ortsteil { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; padding: .25rem 0 .25rem .75rem;
  border-bottom: 1px dotted var(--pico-muted-border-color); font-size: .9rem; }
.ortsteil label { margin: 0; font-size: .85rem; display: flex; gap: .3rem; align-items: center; }
.price-help { margin: .5rem 0 1rem; }

/* Mehrfachauswahl zum Ausblenden */
.batch-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.select-box { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; margin: 0; color: var(--pico-muted-color); }
.select-box input { margin: 0; }
.card.selected { outline: 3px solid var(--pico-primary); outline-offset: -3px; }
.batch-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem;
  padding: .6rem 12px calc(.6rem + env(safe-area-inset-bottom));
  background: var(--pico-card-background-color); border-top: 2px solid var(--pico-primary);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .25);
}
.batch-bar[hidden] { display: none; }
.batch-bar select, .batch-bar input, .batch-bar button { margin: 0; }
.batch-actions { display: flex; gap: .4rem; }
.batch-actions button { flex: 1; }
body.has-batch-bar main { padding-bottom: 15rem; }
@media (min-width: 640px) {
  .batch-bar { grid-template-columns: auto minmax(0, 12rem) minmax(0, 1fr) auto; align-items: center; padding-left: 16px; padding-right: 16px; }
  .batch-actions button { flex: none; }
  body.has-batch-bar main { padding-bottom: 6rem; }
}
