/* Own palette; from Telegram only "light or dark" (body.dark). Jobcenter colours: green = fits,
   orange = needs the +20 % allowance, grey = unclear. Pin fill = age: solid / pale / white. */
:root {
  --bg: #ffffff; --surface: #f4f4f2; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #2160c4; --accent-bg: #e6eefb; --danger: #c0392b;
  --ok: #1e8a45; --ok-pale: #e3f4e8; --mid: #d9770b; --mid-pale: #fdeedb; --unk: #6b6b6b; --unk-pale: #ececea;
  --shadow: 0 1px 4px rgba(0, 0, 0, .18);
  --sheet-peek: 132px;
  --top: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px));
}
body.dark {
  --bg: #1c1c1e; --surface: #2a2a2d; --text: #f2f2f0; --muted: #a3a39e; --line: #3a3a3d;
  --accent: #6aa0ff; --accent-bg: #23324d;
  --ok: #3fbf6a; --ok-pale: #1f3a28; --mid: #f0943a; --mid-pale: #45311b; --unk: #a0a09c; --unk-pale: #39393b;
  --shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#map { position: absolute; inset: 0; }

/* --- pins ----------------------------------------------------------------------------------------
   Two things, two marks (owner, 07.10.2026: one colour for both read as "different freshness"):
   the dot before the price = Jobcenter, the pin's fill = age — blue new (< 3 days), white < 14 days,
   pale grey older. The map is always the light style, so pins keep one look in both themes.
   MapLibre moves the outer .pin-wrap by its transform; looks and the selected scale live on the inner
   .pin, so nothing animates the marker's position (that made pins lag behind the map). */
.pin-wrap { cursor: pointer; }
.pin { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; border-radius: 12px; padding: 3px 8px 3px 6px;
  font-size: 13px; font-weight: 600; line-height: 1.2; background: #ffffff; color: #1d1d1b; border: 1px solid #cfcec8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .12s; }
.pin::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #8a8a85; box-shadow: 0 0 0 1.5px #ffffff; }
.pin.ok::before { background: #1e8a45; }
.pin.raised::before, .pin.over::before { background: #e07b0b; }
.pin.new { background: #2160c4; border-color: #2160c4; color: #ffffff; }
.pin.old { background: #ecebe6; border-color: #dad9d3; color: #77766f; font-weight: 500; font-size: 12px; box-shadow: none; }
.pin.applied::after { content: "✓"; }
.pin.selected { transform: scale(1.18); outline: 3px solid #2160c4; outline-offset: 2px; }
.pin.new.selected { outline-color: #0b2f6b; }
.place-pin { background: #1f2a44; color: #ffffff; border-radius: 12px; padding: 3px 9px 3px 7px; font-size: 13px;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); pointer-events: none; }

/* --- top bar --------------------------------------------------------------------------------------- */
.topbar { position: absolute; top: calc(var(--top) + 10px); left: 10px; right: 10px; z-index: 5; display: flex;
  flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 16px; padding: 6px 12px; font-size: 14px;
  box-shadow: var(--shadow); white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.safety-card { background: var(--bg); border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 12px; color: var(--muted); }
.segmented { display: flex; background: var(--surface); border-radius: 9px; padding: 2px; margin-bottom: 6px; }
.segmented button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 4px 10px; font-size: 13px; }
.segmented button.on { background: var(--bg); box-shadow: var(--shadow); color: var(--text); }
.scale { display: flex; align-items: center; gap: 6px; max-width: 220px; }
.scale-bar { flex: none; width: 60px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #f2eefa, #cdbfe9, #a08bd6, #7559bd, #4b2f93); }

/* --- sheet ----------------------------------------------------------------------------------------- */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--bg); border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .16); display: flex; flex-direction: column;
  height: calc(100% - var(--top) - 56px); transform: translateY(calc(100% - var(--sheet-peek)));
  transition: transform .28s cubic-bezier(.2, .8, .2, 1); will-change: transform; }
.sheet[data-state="half"] { transform: translateY(45%); }
.sheet[data-state="full"] { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-head { flex: none; padding: 8px 16px 6px; touch-action: none; cursor: grab; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 8px; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet[data-state="half"] .sheet-body { padding-bottom: calc(45vh + 16px); }

.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.head-title { font-weight: 600; font-size: 17px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 6px; align-items: center; }
.legend .pin { box-shadow: none; font-size: 11px; padding: 1px 6px; }
.legend .pin.plain::before { display: none; }
.legend-label { color: var(--text); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { box-shadow: none; background: var(--surface); border-color: transparent; }
.chips .chip.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* --- list ------------------------------------------------------------------------------------------ */
.row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.thumb { flex: none; width: 64px; height: 64px; border-radius: 10px; background: var(--surface) center / cover no-repeat; }
.row-main { min-width: 0; flex: 1; }
.row-price { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.row-line { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-line.text { color: var(--text); }
.badge { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 1px 6px; background: var(--ok-pale); color: var(--ok); }
.badge.new { background: var(--accent-bg); color: var(--accent); }
.list-foot { text-align: center; padding: 14px 0 4px; font-size: 13px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); padding: 4px; }
.empty { padding: 24px 0; text-align: center; color: var(--muted); }

/* --- flat ------------------------------------------------------------------------------------------ */
.back { border: 0; background: none; color: var(--accent); padding: 2px 0; font-size: 15px; }
.head-meta { font-size: 13px; color: var(--muted); text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.flat-head { padding: 2px 0 4px; }
.flat-title { font-size: 17px; font-weight: 600; line-height: 1.3; }
.price-line { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.price-big { font-size: 26px; font-weight: 700; }
.jc-badge { align-self: center; margin-left: 4px; font-size: 12px; font-weight: 600; border-radius: 10px; padding: 3px 9px;
  background: var(--unk-pale); color: var(--unk); }
.jc-badge.ok { background: var(--ok-pale); color: var(--ok); }
.jc-badge.raised, .jc-badge.over { background: var(--mid-pale); color: var(--mid); }
.jc-bar { position: relative; height: 8px; border-radius: 4px; background: var(--surface); margin: 10px 0 5px; }
.jc-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--ok); }
.jc-bar.raised .jc-fill, .jc-bar.over .jc-fill { background: var(--mid); }
.jc-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.jc-tick.soft { opacity: .35; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.marks { margin-top: 12px; }
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 12px; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.done { background: var(--ok-pale); border-color: var(--ok); color: var(--ok); width: 100%; }
.btn.marks { width: 100%; }
.callout { border-radius: 12px; padding: 9px 12px; font-size: 14px; margin-top: 12px; display: grid; gap: 4px; }
.callout.warn { background: var(--mid-pale); color: var(--mid); }
.callout.good { background: var(--ok-pale); color: var(--ok); }
.photo { width: 100%; height: 170px; object-fit: cover; border-radius: 12px; display: block; margin-top: 14px; background: var(--surface); }
.section { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.section-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; }
.kv-label { color: var(--muted); flex: none; }
.kv-value { text-align: right; }
.kv.strong { font-weight: 600; border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 7px; }
.kv.strong .kv-label { color: var(--text); }
.flat-original { margin-top: 16px; font-size: 13px; color: var(--muted); font-style: italic; }
.places { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.places::-webkit-scrollbar { display: none; }
.places .chip { box-shadow: none; background: var(--surface); border-color: transparent; }
.places .chip.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.trip-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.walk-chip { font-size: 13px; color: var(--muted); }
.trip-sum { margin-top: 6px; }
.trip-sum .link { font-size: 12px; padding: 0; }
.steps { margin-top: 6px; }
.leg { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 14px; }
.line-badge { flex: none; min-width: 34px; text-align: center; color: #fff; font-weight: 700; font-size: 13px; border-radius: 5px; padding: 1px 5px; background: #777; }
.line-badge.walk { background: var(--surface); color: var(--muted); font-weight: 400; }
.how { white-space: pre-line; font-size: 14px; background: var(--surface); border-radius: 12px; padding: 10px 12px; }

/* Pinned at the screen's bottom, not the sheet's: in the half state the sheet's own bottom is off-screen. */
.actionbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: grid; grid-template-columns: 2fr 1fr; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.sheet.with-bar .sheet-body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.sheet.with-bar[data-state="half"] .sheet-body { padding-bottom: calc(45vh + 80px); }
.modal { position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; }
.modal-panel { width: 100%; max-height: 85%; overflow-y: auto; background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.modal-title { font-size: 17px; font-weight: 600; }

/* --- toast and splash -------------------------------------------------------------------------------- */
.toast { position: absolute; left: 12px; right: 12px; bottom: calc(var(--sheet-peek) + 12px); z-index: 9; background: #2b2b2b;
  color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  box-shadow: var(--shadow); font-size: 14px; }
.toast button { border: 0; background: none; color: #8fb8ff; font-weight: 600; padding: 2px 4px; }
.splash { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; transition: opacity .25s; }
body:not(.booting) .splash { opacity: 0; pointer-events: none; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sheet, .pin, .splash { transition: none; } .spinner { animation-duration: 3s; } }
.maplibregl-ctrl-attrib { font-size: 10px; }
