/* Self-hosted (Latin subset only -- covers Swedish å/ä/ö), not loaded live
   from Google: that pattern has drawn real EU enforcement action for
   exposing visitor IPs to Google before any consent choice. */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/dm-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: italic;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/libre-franklin-800italic.woff2') format('woff2');
}

:root {
  --ink: #182420;
  --paper: #faf8f2;
  --surface: #ffffff;
  --accent: #0f5646;
  --accent-dark: #0a4034;
  --accent-soft: #e6efe9;
  --line: #e2ded2;
  --muted: #6c6a5c;
  --red: #a5392a;
  --shadow-ink: 23, 32, 28;
  --shadow-accent: 15, 86, 70;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Libre Franklin", sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 4vw;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; font: 700 18px "Libre Franklin", sans-serif; letter-spacing: -.04em; white-space: nowrap; }
.brand span { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px; border-radius: 8px; background: var(--accent); color: #fff; font: 700 12px "Libre Franklin"; }
.header-actions { display: flex; align-items: center; gap: 16px; font-size: 11px; color: var(--muted); }
.header-actions button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; font: 600 12px "Libre Franklin"; transition: border-color .15s ease, transform .1s ease; }
.header-actions button:hover { border-color: var(--accent); color: var(--accent); }
.header-actions button:active { transform: translateY(1px); }
.header-actions button[hidden] { display: none; }
#scan-status { display: inline-flex; align-items: center; gap: 6px; }
#scan-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.clock { color: var(--muted); font: 11px "DM Mono"; }

main { width: min(1600px, 94vw); margin: 0 auto; }

.login-panel { margin-top: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 1px 2px rgba(var(--shadow-ink), .04); }
.login-panel[hidden] { display: none; }
.login-panel summary { cursor: pointer; font-weight: 600; }
.login-panel form { display: flex; gap: 12px; align-items: end; padding: 15px 0 0; }
.login-panel label { flex: 1; margin: 0; }
.login-panel p { margin: 8px 0 0; }

.search-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 36px 0 26px; }
.search-heading p { margin: 0 0 8px; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.search-heading h1 { margin: 0; font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -.045em; line-height: 1.05; font-weight: 800; }
.saved-tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }

label { display: block; }
input, select, textarea {
  display: block; width: 100%; font: 14px "Libre Franklin"; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
:focus-visible { outline: 3px solid #79c2a8; outline-offset: 2px; }
input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid #79c2a8; outline-offset: 2px; }

.catalog-controls {
  display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1.3fr) minmax(150px, 1fr) minmax(140px, 1fr) auto auto;
  align-items: end; gap: 12px; padding: 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(var(--shadow-ink), .04), 0 16px 32px -18px rgba(var(--shadow-ink), .18);
}
.catalog-controls label { color: var(--ink); font: 600 12px "Libre Franklin"; margin: 0; }
.catalog-controls input, .catalog-controls select, .result-summary select { min-height: 46px; margin-top: 7px; }
.more-filters { position: relative; }
.more-filters summary, .clear-filters { display: grid; place-items: center; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); cursor: pointer; font: 600 12px "Libre Franklin"; white-space: nowrap; transition: border-color .15s ease, color .15s ease; }
.more-filters summary { list-style: none; }
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters[open] summary { border-color: var(--accent); color: var(--accent); }
.more-filter-fields { position: absolute; z-index: 1100; top: 54px; right: 0; width: min(340px, 90vw); padding: 16px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 20px 40px -16px rgba(var(--shadow-ink), .28); }
.clear-filters:hover, .more-filters summary:hover { border-color: var(--accent); color: var(--accent); }

.result-summary { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 22px 2px 14px; border-bottom: 1px solid var(--line); font-family: "Libre Franklin", sans-serif; }
.result-summary strong { font-size: 18px; }
.result-summary span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.result-actions { display: flex; align-items: end; gap: 12px; }
.result-actions label { margin: 0; color: var(--muted); }
.check-inline { display: flex; align-items: center; gap: 6px; font: 600 12px "Libre Franklin", sans-serif; }
.check-inline input { width: auto; margin: 0; }
.result-summary select { min-height: 38px; margin-top: 3px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.view-switch button { min-width: 58px; border: 0; border-radius: 6px; padding: 8px 12px; background: transparent; color: var(--muted); cursor: pointer; font: 600 12px "Libre Franklin"; transition: background .15s ease, color .15s ease; }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
#filter-status { min-height: 15px; margin: 8px 0; color: var(--muted); font-size: 12px; }

.results-layout { display: grid; grid-template-columns: minmax(400px, 47%) minmax(0, 1fr); gap: 18px; align-items: start; }
.results-layout.list-active { grid-template-columns: minmax(0, 1fr); }
.results-layout.list-active #map-panel { display: none; }
.listings { display: flex; flex-direction: column; gap: 14px; padding: 0 0 80px; }
.load-more { align-self: center; min-height: 44px; margin: 12px 0; padding: 0 22px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 13px "Libre Franklin"; cursor: pointer; transition: background .15s ease, color .15s ease, transform .1s ease; }
.load-more:hover { background: var(--accent); color: #fff; }
.load-more:active { transform: translateY(1px); }

.card {
  display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 186px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: 0 1px 2px rgba(var(--shadow-ink), .03), 0 10px 24px -16px rgba(var(--shadow-ink), .14);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: #cfe4da; box-shadow: 0 4px 10px rgba(var(--shadow-ink), .05), 0 22px 34px -18px rgba(var(--shadow-accent), .28); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--shadow-accent), .22); }
.listing-image { display: block; width: 190px; height: 100%; min-height: 186px; overflow: hidden; background: var(--accent-soft); }
.image-fallback { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.kind-apartment { --pin-color: #285a91; }
.kind-house { --pin-color: #934638; }
.kind-country { --pin-color: #2d704b; }
.kind-plot { --pin-color: #78528c; }
.kind-other { --pin-color: #4c5c67; }
.kind-mixed { --pin-color: #0f5646; }
.home-pin, .map-group { display: grid; place-items: center; background: var(--pin-color); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 2px 8px #122a2466; color: #fff; }
.home-pin svg { width: 19px; height: 19px; }
.home-pin.is-approximate { border-style: dashed; opacity: .75; }
.home-pin.is-selected { outline: 3px solid #ecb651; outline-offset: 2px; z-index: 1; }
.map-group { width: 48px; height: 48px; border-width: 3px; grid-template-rows: 20px 14px; align-content: center; font-weight: 700; font-size: 12px; line-height: 1; }
.map-group.kind-mixed { grid-template-rows: auto; }
.map-group svg { width: 15px; height: 15px; }
.listing-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.listing-image:hover img { transform: scale(1.03); }
.card-content { min-width: 0; padding: 16px 18px; }
.card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.source { background: none; color: var(--accent); padding: 0; font-weight: 700; }
.upcoming { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 4px; background: #f2e5c6; color: #614a18; font-size: 10px; }
.card h2 { margin: 9px 0 4px; font-size: 19px; line-height: 1.2; letter-spacing: -.03em; font-weight: 700; }
.card-title { display: inline; margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.card .area { margin: 0; font-size: 12px; color: var(--muted); }
.card .price { margin: 10px 0; font: 700 18px "Libre Franklin"; }
.price-drop { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-dark); font: 700 11px "Libre Franklin"; vertical-align: middle; }
.facts { display: flex; gap: 8px; flex-wrap: wrap; }
.fact { border: 0; padding: 0; color: var(--muted); font: 12px "Libre Franklin"; }
.fact:not(:last-child)::after { content: " ·"; }
.commutes { display: flex; gap: 8px; margin-top: 10px; }
.commute { padding: 5px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--muted); font: 10px "Libre Franklin"; }
.commute strong { display: inline; margin-left: 4px; color: var(--ink); font: 700 11px "Libre Franklin"; }
.commute.bad { background: #fbe8e4; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions a, .actions button {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; color: var(--ink); font: 600 12px "Libre Franklin"; text-decoration: none; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.actions a:hover, .actions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.actions button[data-dismiss-id] { color: var(--muted); }
.actions button[data-dismiss-id]:hover { border-color: var(--red); color: var(--red); background: #fbe8e4; }

#map-panel { position: sticky; top: 16px; height: calc(100vh - 32px); min-height: 500px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--accent-soft); box-shadow: 0 1px 2px rgba(var(--shadow-ink), .03), 0 16px 32px -20px rgba(var(--shadow-ink), .18); }
#map { width: 100%; height: 100%; }
.map-legend { position: absolute; z-index: 500; top: 12px; right: 12px; margin: 0; padding: 9px 11px; background: #fffffff2; border-radius: var(--radius-sm); box-shadow: 0 6px 16px rgba(var(--shadow-ink), .18); color: var(--ink); font-size: 11px; }
.map-legend summary { cursor: pointer; font-weight: 700; }
.map-legend-items { display: grid; gap: 5px; margin-top: 8px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--pin-color); color: #fff; font-size: 15px; line-height: 1; }
.map-legend b svg { width: 13px; height: 13px; }
.map-legend small { color: var(--muted); }
#map-status { position: absolute; z-index: 500; left: 12px; bottom: 12px; max-width: calc(100% - 24px); margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: #fffffff2; color: var(--ink); font-size: 11px; box-shadow: 0 6px 16px rgba(var(--shadow-ink), .18); }
.map-popup strong { display: block; font-size: 14px; }
.map-popup span { display: block; margin: 4px 0; }
.map-popup a { color: var(--accent); }
.map-popup .approx-note { color: #8a6415; font-size: 11px; }
.location-note { color: #8a6415; font-size: 12px; margin: 2px 0 0; }
.leaflet-control-zoom { border: none !important; border-radius: var(--radius-sm) !important; overflow: hidden; box-shadow: 0 4px 14px rgba(var(--shadow-ink), .18) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; }

.empty { border: 1px dashed var(--line); border-radius: var(--radius-md); padding: 30px; background: var(--surface); text-align: center; color: var(--muted); }

dialog { background: var(--surface); color: var(--ink); border: 0; border-radius: var(--radius-lg); box-shadow: 0 30px 60px -20px rgba(var(--shadow-ink), .35); }
dialog::backdrop { background: rgba(24, 36, 32, .45); }
form { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; }
.dialog-head small { font: 11px "DM Mono"; letter-spacing: .1em; color: var(--muted); }
.dialog-head h2 { font-size: 30px; margin: 6px 0 22px; letter-spacing: -.03em; }
.dialog-head button { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.dialog-head button:hover { color: var(--ink); }
form label { font: 11px "DM Mono"; margin-bottom: 14px; }
dialog input, dialog select, dialog textarea { background: var(--surface); border-color: var(--line); color: var(--ink); }
.lede { max-width: 65ch; color: var(--muted); }
.error { color: var(--red); font: 12px "DM Mono"; min-height: 14px; }

#detail-dialog { padding: 28px; width: min(760px, 92vw); max-height: 88vh; overflow: auto; }
.detail-body { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 22px; margin-top: 6px; }
.detail-image { display: block; min-height: 200px; border-radius: var(--radius-md); overflow: hidden; background: var(--accent-soft); }
.detail-image[hidden] { display: none; }
.detail-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-info { min-width: 0; }
.detail-info .area { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.detail-info .price { margin: 10px 0; font: 700 22px "Libre Franklin"; }
.detail-info .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.detail-info .commutes { display: flex; gap: 8px; margin: 10px 0 0; }
.detail-info .actions { margin-top: 18px; }
@media (max-width: 640px) {
  .detail-body { grid-template-columns: 1fr; }
  .detail-image { max-height: 220px; }
}

.primary { border: 0; background: var(--accent); color: #fff; padding: 14px 19px; border-radius: var(--radius-sm); font: 600 13px "Libre Franklin"; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.primary:hover { background: var(--accent-dark); }
.primary:active { transform: translateY(1px) scale(.99); }

.account-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 28px 24px; border-top: 1px solid var(--line); }
.account-controls button { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 9px 14px; font: 600 12px "Libre Franklin", sans-serif; cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.account-controls button:hover { border-color: var(--accent); color: var(--accent); }
.account-controls button.danger { border-color: var(--red); color: var(--red); }
.account-controls button.danger:hover { background: var(--red); color: #fff; }
.account-controls #account-status { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .catalog-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .more-filters, .clear-filters { grid-column: auto; }
  .results-layout { grid-template-columns: minmax(360px, 52%) minmax(0, 1fr); }
  .card { grid-template-columns: 135px minmax(0, 1fr); }
  .listing-image { width: 135px; }
}
@media (max-width: 750px) {
  header { padding: 0 4vw; }
  .header-actions #scan-status, .clock { display: none; }
  .search-heading { padding: 26px 0 20px; }
  .saved-tools #forward-address { display: none; }
  .catalog-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
  .catalog-controls label:first-child { grid-column: 1 / -1; }
  .result-summary { align-items: center; }
  .result-actions { flex-wrap: wrap; justify-content: end; }
  .results-layout { display: block; }
  #map-panel { display: none; position: relative; top: auto; height: calc(100dvh - 190px); min-height: 400px; }
  .results-layout.map-active .listings { display: none; }
  .results-layout.map-active #map-panel { display: block; }
  .login-panel form { display: block; }
  .login-panel button { margin-top: 10px; }
}
@media (max-width: 480px) {
  .saved-tools { display: none; }
  .catalog-controls { grid-template-columns: 1fr 1fr; }
  .catalog-controls label:nth-child(2), .catalog-controls label:nth-child(3), .catalog-controls label:nth-child(4) { grid-column: 1 / -1; }
  .more-filters, .clear-filters { grid-column: span 1; }
  .result-summary { align-items: start; }
  .result-actions label { display: none; }
  .card { grid-template-columns: 110px minmax(0, 1fr); min-height: 150px; }
  .listing-image { width: 110px; min-height: 150px; }
  .card-content { padding: 12px; }
  .card h2 { font-size: 16px; }
  .card .price { font-size: 15px; }
  .card .top { font-size: 10px; }
  .actions { gap: 7px; }
  .actions a, .actions button { font-size: 11px; padding: 5px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
