/* Wohnradar – Apple-inspiriertes Design (iOS/macOS), hell & dunkel */

:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --pink: #ff2d55;
  --indigo: #5856d6;
  --purple: #af52de;
  --teal: #30b0c7;
  /* Miete vs. Kauf – überall gleich */
  --rent: #007aff;
  --rent-soft: rgba(0, 122, 255, 0.12);
  --buy: #af52de;
  --buy-soft: rgba(175, 82, 222, 0.13);
  --glass: rgba(249, 249, 251, 0.78);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --card: #1c1c1e;
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --pink: #ff375f;
    --indigo: #5e5ce6;
    --purple: #bf5af2;
    --teal: #40c8e0;
    --rent: #0a84ff;
    --rent-soft: rgba(10, 132, 255, 0.2);
    --buy: #bf5af2;
    --buy-soft: rgba(191, 90, 242, 0.2);
    --glass: rgba(28, 28, 30, 0.72);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */

#view {
  min-height: 100vh;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 1180px;
  margin: 0 auto;
}
#view.full { padding: 0; max-width: none; height: 100vh; height: 100dvh; }

.large-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 4px 14px;
}
.large-title h1 { font-size: 34px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.large-title .sub { color: var(--label-2); font-size: 15px; margin-top: 4px; }
.title-actions { display: flex; gap: 8px; align-items: center; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 4px 10px; }
.section-title h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.section-title a, .section-title button.link { font-size: 15px; }

/* ---------- Tab-Leiste (iOS) / Seitenleiste (Desktop) ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b));
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: 0;
  padding: 4px 0;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--label-2);
  position: relative;
}
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--blue); }
.tab .dot {
  position: absolute; top: 0; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.brand { display: none; }

@media (min-width: 960px) {
  body { --tabbar-h: 0px; }
  .tabbar {
    top: 0; right: auto; width: 232px;
    flex-direction: column; justify-content: flex-start; gap: 2px;
    padding: 22px 12px;
    border-top: 0; border-right: 0.5px solid var(--sep);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; padding: 4px 10px 18px; letter-spacing: -0.02em; }
  .brand .logo { width: 30px; height: 30px; }
  .tab { flex: 0; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 9px 12px; border-radius: 10px; font-size: 15px; color: var(--label); }
  .tab svg { width: 22px; height: 22px; color: var(--blue); }
  .tab.active { background: var(--fill); color: var(--label); font-weight: 600; }
  .tab .dot { position: static; margin-left: auto; }
  #view { margin-left: 232px; padding: 18px 40px 40px; max-width: 1240px; }
  #view.full { margin-left: 232px; }
}

/* ---------- Bausteine ---------- */

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.group { background: var(--card); border-radius: var(--radius-sm); overflow: hidden; }
.group + .group { margin-top: 18px; }
.group-label { font-size: 13px; text-transform: uppercase; color: var(--label-2); margin: 22px 16px 7px; letter-spacing: 0.02em; }
.group-foot { font-size: 13px; color: var(--label-2); margin: 7px 16px 0; line-height: 1.4; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 46px; padding: 10px 16px;
  position: relative; background: none; border: 0; width: 100%; text-align: left;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row .meta { color: var(--label-2); font-size: 15px; }
.row .chev { color: var(--label-3); width: 9px; flex: none; }
.row .icon-badge { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; font-size: 16px; }
.row input[type="text"], .row input[type="number"], .row input[type="email"], .row input[type="password"], .row input[type="time"], .row select {
  border: 0; background: none; outline: none; text-align: right; flex: 1; min-width: 0; color: var(--label-2);
}
.row input:focus { color: var(--label); }
.row label { flex: none; }
.row.stack { flex-direction: column; align-items: stretch; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 16px;
  transition: transform 0.15s ease, opacity 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; }
.btn.secondary { background: var(--fill); color: var(--blue); }
.btn.plain { background: none; color: var(--blue); padding: 8px 10px; }
.btn.danger { background: rgba(255, 59, 48, 0.12); color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 18px; border: 0;
  display: grid; place-items: center; background: var(--fill); color: var(--blue); flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.glass { background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--shadow); }

.field {
  width: 100%; border: 0; border-radius: 12px; padding: 12px 14px;
  background: var(--fill); outline: none; font-size: 17px;
}
.field:focus { box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.35); }
textarea.field { resize: vertical; min-height: 90px; line-height: 1.4; }

.search-field { position: relative; }
.search-field svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; color: var(--label-2); }
.search-field input { padding-left: 36px; }

/* Segment-Steuerung */
.segmented {
  display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill); gap: 2px; position: relative;
}
.segmented button {
  border: 0; background: none; padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--label);
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button.on { background: var(--bg-elev); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); font-weight: 600; }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; justify-content: center; }
.segmented .sw { width: 8px; height: 8px; border-radius: 4px; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 0; border-radius: 16px; padding: 6px 13px; background: var(--fill); font-size: 14px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--label); color: var(--bg-elev); }
.chip .n { opacity: 0.6; font-variant-numeric: tabular-nums; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 7px; letter-spacing: 0.01em; white-space: nowrap;
}
.badge.rent { background: var(--rent); color: #fff; }
.badge.buy { background: var(--buy); color: #fff; }
.badge.soft-rent { background: var(--rent-soft); color: var(--rent); }
.badge.soft-buy { background: var(--buy-soft); color: var(--buy); }
.badge.off { background: var(--red); color: #fff; }
.badge.unknown { background: var(--fill-2); color: var(--label-2); }
.badge.down { background: rgba(52, 199, 89, 0.16); color: var(--green); }
.badge.up { background: rgba(255, 59, 48, 0.13); color: var(--red); }
.badge.new { background: var(--orange); color: #fff; }
.badge.glass { background: rgba(0, 0, 0, 0.45); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.badge svg { width: 12px; height: 12px; }

/* ---------- Inserats-Karten ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.lcard {
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s;
  position: relative; border: 0; padding: 0; text-align: left; width: 100%;
}
.lcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lcard:active { transform: scale(0.985); }
.lcard .media { position: relative; aspect-ratio: 16 / 10; background: var(--fill); overflow: hidden; }
.lcard .media img { width: 100%; height: 100%; object-fit: cover; }
.lcard .media .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--label-3); }
.lcard .media .ph svg { width: 44px; }
.lcard .tl { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.lcard .tr { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.lcard .bl { position: absolute; bottom: 10px; left: 10px; display: flex; gap: 6px; }
.lcard.offline .media img { filter: grayscale(1) opacity(0.6); }
.lcard .stripe { height: 4px; }
.lcard.rent .stripe { background: var(--rent); }
.lcard.buy .stripe { background: var(--buy); }
.lcard .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.lcard .price { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.lcard .price small { font-size: 13px; font-weight: 600; color: var(--label-2); }
.lcard .old-price { font-size: 14px; color: var(--label-2); text-decoration: line-through; font-weight: 500; }
.lcard .title { font-size: 15px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lcard .facts { font-size: 14px; color: var(--label-2); display: flex; gap: 10px; flex-wrap: wrap; }
.lcard .loc { font-size: 13px; color: var(--label-2); display: flex; align-items: center; gap: 4px; }
.lcard .loc svg { width: 13px; }
.lcard .commutes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.commute-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: var(--fill); }
.commute-chip i { width: 8px; height: 8px; border-radius: 4px; display: inline-block; }
.stars { color: var(--orange); letter-spacing: 1px; font-size: 13px; }
.stage-pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--fill); color: var(--label-2); }

/* Kompakte Liste */
.lrow { display: flex; gap: 12px; padding: 10px; align-items: center; border: 0; background: none; width: 100%; text-align: left; position: relative; }
.lrow + .lrow::before { content: ""; position: absolute; top: 0; left: 104px; right: 0; border-top: 0.5px solid var(--sep); }
.lrow .thumb { width: 84px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--fill); flex: none; position: relative; }
.lrow .thumb img { width: 100%; height: 100%; object-fit: cover; }
.lrow .thumb .badge { position: absolute; left: 4px; bottom: 4px; font-size: 10px; padding: 2px 5px; }
.lrow .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .s { font-size: 13px; color: var(--label-2); }

/* ---------- Übersicht ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); border: 0; text-align: left; }
.stat .n { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--label-2); font-weight: 500; }
.stat .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; margin-bottom: 8px; }
.stat .ic svg { width: 18px; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare .side { padding: 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.compare .side::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.compare .side.rent::before { background: var(--rent); }
.compare .side.buy::before { background: var(--buy); }
.compare h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.compare .big { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.compare .small { font-size: 13px; color: var(--label-2); }

.feed .row { align-items: flex-start; }
.feed .emoji { font-size: 22px; width: 30px; text-align: center; flex: none; }
.feed .t { font-weight: 600; font-size: 15px; }
.feed .b { font-size: 14px; color: var(--label-2); }
.feed .time { font-size: 12px; color: var(--label-3); white-space: nowrap; }
.feed .unread::after { content: ""; position: absolute; left: 6px; top: 50%; width: 7px; height: 7px; margin-top: -3px; border-radius: 4px; background: var(--blue); }

.import-bar { display: flex; gap: 8px; }
.import-bar .field { flex: 1; }

.empty { text-align: center; padding: 48px 20px; color: var(--label-2); }
.empty .em { font-size: 52px; margin-bottom: 8px; }
.empty h3 { color: var(--label); margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 auto 16px; max-width: 380px; font-size: 15px; }

/* ---------- Bottom-Sheet / Modal ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.32);
  opacity: 0; transition: opacity 0.25s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 101; left: 0; right: 0; bottom: 0;
  max-height: calc(100vh - var(--safe-t) - 28px); max-height: calc(100dvh - var(--safe-t) - 28px);
  background: var(--bg); border-radius: 14px 14px 0 0;
  transform: translateY(100%); transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}
.sheet.open { transform: translateY(0); }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 6px 16px; flex: none; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.sheet-head .btn.plain { min-width: 70px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 16px calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet.tall { height: calc(100vh - var(--safe-t) - 28px); height: calc(100dvh - var(--safe-t) - 28px); }
.sheet.flush .sheet-body { padding: 0 0 calc(24px + var(--safe-b)); }
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(720px, calc(100vw - 48px)); border-radius: 16px; transform: translate(-50%, -46%) scale(0.98); opacity: 0; transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s; max-height: calc(100vh - 64px); }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.tall { height: min(900px, calc(100vh - 64px)); }
  .sheet.wide { width: min(1080px, calc(100vw - 48px)); }
  .sheet .grabber { display: none; }
}

/* ---------- Exposé (Detail) ---------- */

.gallery { position: relative; background: #000; aspect-ratio: 16 / 10; max-height: 52vh; width: 100%; }
.gallery .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: 100%; scrollbar-width: none; }
.gallery .track::-webkit-scrollbar { display: none; }
.gallery .track img { flex: none; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.gallery .count { position: absolute; right: 12px; bottom: 12px; }
.gallery .nav { position: absolute; top: 50%; transform: translateY(-50%); }
.gallery .nav.prev { left: 10px; }
.gallery .nav.next { right: 10px; }
.gallery .tl { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
.detail { padding: 16px; }
.detail .head .price { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.detail .head h1 { font-size: 20px; margin: 4px 0 6px; line-height: 1.25; letter-spacing: -0.015em; }
.detail .head .loc { color: var(--label-2); font-size: 15px; }
.keyfacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.keyfacts div { background: var(--card); border-radius: 14px; padding: 12px; }
.keyfacts b { display: block; font-size: 19px; letter-spacing: -0.02em; }
.keyfacts span { font-size: 12.5px; color: var(--label-2); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.actions-row .btn { flex: 1; min-width: 140px; }
.desc { white-space: pre-line; font-size: 15px; line-height: 1.5; color: var(--label); }
.desc.clamp { max-height: 9.5em; overflow: hidden; mask-image: linear-gradient(#000 60%, transparent); -webkit-mask-image: linear-gradient(#000 60%, transparent); }
.features { display: flex; flex-wrap: wrap; gap: 6px; }
.features span { font-size: 13px; padding: 5px 10px; border-radius: 8px; background: var(--card); }
.minimap { height: 220px; border-radius: 14px; overflow: hidden; }
.stage-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-picker button { border: 0; padding: 8px 12px; border-radius: 10px; background: var(--card); font-size: 14px; font-weight: 500; }
.stage-picker button.on { background: var(--blue); color: #fff; }
.rating { display: flex; gap: 4px; }
.rating button { background: none; border: 0; font-size: 26px; padding: 0 2px; color: var(--label-3); }
.rating button.on { color: var(--orange); }

/* Preisverlauf */
.chart { width: 100%; height: 150px; display: block; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.12; }
.chart .grid-l { stroke: var(--sep); stroke-width: 1; }
.chart text { fill: var(--label-2); font-size: 11px; font-family: var(--font); }
.chart circle { stroke: var(--card); stroke-width: 2; }

/* Pendeln & Umgebung */
.commute-list .row .min { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dotc { width: 12px; height: 12px; border-radius: 6px; flex: none; }
.poi-tabs { margin: 8px 0 10px; }
.poi-list .row { min-height: 52px; }
.poi-list .dist { font-variant-numeric: tabular-nums; color: var(--label-2); font-size: 14px; white-space: nowrap; }
.poi-detail { font-size: 13px; color: var(--label-2); margin-top: 2px; }
.poi-detail a { word-break: break-all; }

/* ---------- Karte ---------- */

.map-wrap { position: relative; height: 100%; width: 100%; }
.map { position: absolute; inset: 0; }
.map-top {
  position: absolute; top: calc(var(--safe-t) + 12px); left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; pointer-events: none;
}
.map-top > * { pointer-events: auto; }
.map-top .segmented { background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow); }
.layer-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.layer-toggles .chip { background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow); }
.layer-toggles .chip.on { background: var(--label); color: var(--bg-elev); }
.map-right { position: absolute; right: 12px; top: calc(var(--safe-t) + 64px); z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.map-panel {
  position: absolute; z-index: 6; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  background: var(--glass); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 12px; max-height: 52vh; overflow-y: auto;
  animation: pop 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@media (min-width: 960px) { .map-panel { left: auto; width: 400px; bottom: auto; top: 64px; max-height: calc(100% - 84px); } }
@keyframes pop { from { transform: translateY(20px); opacity: 0; } }
.map-hint {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500;
  white-space: nowrap;
}

.pin {
  padding: 4px 9px; border-radius: 12px; font-size: 12.5px; font-weight: 700; color: #fff; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); border: 2px solid #fff; cursor: pointer; transition: transform 0.15s;
  font-variant-numeric: tabular-nums;
}
.pin::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff; border-bottom: 0; }
.pin.rent { background: var(--rent); }
.pin.buy { background: var(--buy); }
.pin.offline { background: #8e8e93; text-decoration: line-through; }
.pin.hit { opacity: 0.88; border-style: dashed; }
.pin.sel { transform: scale(1.18); z-index: 3; box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3); }
.wp-pin { width: 34px; height: 34px; border-radius: 17px; border: 3px solid #fff; display: grid; place-items: center; color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); font-size: 16px; }
.poi-pin { width: 26px; height: 26px; border-radius: 13px; border: 2px solid #fff; display: grid; place-items: center; font-size: 13px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3); cursor: pointer; }
.poi-pin.kita { background: #ffcc00; }
.poi-pin.school { background: #34c759; }
.poi-pin.supermarket { background: #ff9500; }
.poi-pin.bakery { background: #a2845e; }
.maplibregl-popup-content { border-radius: 14px !important; padding: 12px 14px !important; background: var(--bg-elev) !important; color: var(--label); box-shadow: var(--shadow-lg) !important; font-family: var(--font); font-size: 14px; max-width: 280px; }
.maplibregl-popup-tip { border-top-color: var(--bg-elev) !important; border-bottom-color: var(--bg-elev) !important; }
.maplibregl-popup-close-button { font-size: 18px; right: 6px !important; top: 4px !important; color: var(--label-2); }
.maplibregl-ctrl-attrib { font-size: 10px; }
.draw-canvas { position: absolute; inset: 0; z-index: 4; touch-action: none; cursor: crosshair; }

/* ---------- Suchaufträge ---------- */

.search-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; border: 0; text-align: left; width: 100%; }
.search-card h3 { margin: 0; font-size: 18px; letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; }
.search-card .crit { font-size: 14px; color: var(--label-2); }
.search-card .foot { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--label-2); flex-wrap: wrap; }
.search-card .area-preview { height: 110px; border-radius: 12px; overflow: hidden; background: var(--fill); position: relative; }
.search-card .area-preview svg { width: 100%; height: 100%; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--fill-2); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.editor-map { height: 340px; border-radius: 14px; overflow: hidden; position: relative; }
.editor-map .map-top { top: 10px; left: 10px; right: 10px; }
.range-row { display: flex; gap: 8px; align-items: center; }
.range-row input[type="range"] { flex: 1; accent-color: var(--blue); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.form-grid label, .lbl { font-size: 13px; color: var(--label-2); display: flex; flex-direction: column; gap: 5px; font-weight: 500; }
.toggle { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill-2); position: relative; flex: none; transition: background 0.2s; cursor: pointer; }
.toggle::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1); }
.toggle:checked { background: var(--green); }
.toggle:checked::after { transform: translateX(20px); }
.suggest { position: relative; }
.suggest .list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--bg-elev); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.suggest .list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 14px; font-size: 15px; }
.suggest .list button + button { border-top: 0.5px solid var(--sep); }
.suggest .list button:hover { background: var(--fill); }
.suggest .list small { display: block; color: var(--label-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Anmeldung ---------- */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(0, 122, 255, 0.18), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(175, 82, 222, 0.18), transparent 60%), var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 28px 24px; }
.auth-card .logo { width: 64px; height: 64px; margin: 0 auto 12px; }
.auth-card h1 { text-align: center; font-size: 28px; margin: 0 0 4px; letter-spacing: -0.03em; }
.auth-card p.lead { text-align: center; color: var(--label-2); margin: 0 0 20px; font-size: 15px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card .switch { text-align: center; margin-top: 16px; font-size: 15px; }
.auth-card .switch button { background: none; border: 0; color: var(--blue); font-weight: 500; }
.err { color: var(--red); font-size: 14px; min-height: 1em; text-align: center; }
.legal { text-align: center; font-size: 12px; color: var(--label-2); margin-top: 18px; }
.legal a { color: var(--label-2); text-decoration: underline; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 200; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 20px); opacity: 0; transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  background: rgba(30, 30, 32, 0.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast button { background: none; border: 0; color: #64d2ff; font-weight: 600; }
@media (min-width: 960px) { .toast { left: calc(50% + 116px); } }

.muted { color: var(--label-2); }
.small { font-size: 13px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.note-box { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--label-2); line-height: 1.45; }
.note-box.warn { background: rgba(255, 149, 0, 0.12); color: var(--label); }
.note-box b { color: var(--label); }
code.bm { display: block; padding: 10px; border-radius: 10px; background: var(--fill); font-size: 12px; word-break: break-all; max-height: 90px; overflow: auto; }
.bookmarklet { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; background: var(--blue); color: #fff; font-weight: 600; cursor: grab; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Preisbewertung */
.vscale { position: relative; margin: 18px 0 4px; }
.vbar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; height: 12px; border-radius: 6px; overflow: hidden; }
.vmarker { position: absolute; top: -7px; transform: translateX(-50%); }
.vmarker i { display: block; width: 6px; height: 26px; border-radius: 3px; background: var(--label); box-shadow: 0 0 0 3px var(--card); }
.vlabels { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 10px; font-size: 11.5px; color: var(--label-2); text-align: center; }
.vlabels span.on { color: var(--label); font-weight: 700; }
.lcard .val { font-size: 12px; font-weight: 700; }
