:root {
  --bg: #ffffff;
  --ink: #14233b;
  --muted: #68737f;
  --accent: #ff4f40;
  --accent-strong: #dc3a2d;
  --line: #e6e8ec;
  --soft: #f4f5f7;
  --peach: #ffece6;
  --ok: #0e8a5f;
  --radius: 18px;
  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 500 16px/1.45 var(--sans); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.muted { color: var(--muted); font-weight: 500; }

/* topp */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 20px 10px; background: var(--bg); }
h1 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: var(--accent); }
.radar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px;
  font-weight: 600; color: var(--muted); background: var(--soft); white-space: nowrap; }
.radar .dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: #aab1ba; }
.radar[data-on="true"] { color: var(--ok); background: #e6f6ef; }
.radar[data-on="true"] .dot { background: var(--ok); }
.radar[data-on="true"] .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--ok); animation: ping 2.8s ease-out infinite; }
@keyframes ping { from { transform: scale(1); opacity: .5; } 70%, to { transform: scale(3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .radar .dot::after { animation: none !important; } }

.top-right { display: flex; align-items: center; gap: 10px; }
.top-favs { display: none; }
.fav-count:empty { display: none; }
.fav-count::before { content: "("; } .fav-count::after { content: ")"; }
main { padding: 6px 20px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
body[data-view="feed"] #filters, body[data-view="filters"] #view-feed,
body[data-view="favs"] #filters, body[data-view="favs"] #view-feed,
body[data-view="listing"] #filters, body[data-view="listing"] #view-feed { display: none; }
body:not([data-view="favs"]) #view-favs { display: none; }
body:not([data-view="listing"]) #view-listing { display: none; }

/* slå på notiser */
.enable { padding: 22px; margin-bottom: 16px; border-radius: 24px; background: var(--peach); }
.enable h2 { font-size: 25px; line-height: 1.12; letter-spacing: -.03em; margin-bottom: 6px; }
.enable p { margin: 0 0 16px; font-size: 15px; color: #47525f; }
.enable .primary { width: 100%; }
.enable .msg { margin: 12px 0 0; color: var(--ink); font-weight: 600; }
.enable .msg:empty { display: none; }

/* sökruta */
.summary { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; text-align: left;
  min-height: 56px; padding: 8px 22px; margin-bottom: 28px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: 0 2px 10px rgba(20, 35, 59, .08); }
.summary .what { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; font-weight: 600; }
.summary .edit { flex: none; color: var(--accent-strong); font-size: 14px; font-weight: 700; }

/* utan bild: låg ruta, så listan inte fylls av tomma ytor */
.ph.noimg { aspect-ratio: 4 / 1; min-height: 76px; }
.ph.noimg .tile { font-size: 20px; place-items: end start; padding: 0 16px 10px; }

/* sparade bevakningar */
.pills { display: flex; gap: 8px; margin: 0 -20px 26px; padding: 2px 20px; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pills button { flex: none; min-height: 42px; max-width: 220px; padding: 0 16px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border: 1px solid #cdd2d9; border-radius: 999px; background: var(--bg); font-size: 15px; font-weight: 600; }
.pills button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.list-head .form-title { margin: 0; }
button.ghost.small { min-height: 40px; padding: 0 14px; border-radius: 999px; }
.watch-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 26px; }
.watch-card { display: block; width: 100%; padding: 14px 16px; text-align: left; border: 1px solid var(--line);
  border-radius: 16px; background: var(--bg); box-shadow: 0 1px 6px rgba(20, 35, 59, .06); }
.watch-card.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.watch-card b { display: block; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.watch-card span { display: block; font-size: 14px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* flöde */
.feed-count { margin: -8px 0 14px; font-size: 14px; color: var(--muted); }
.feed-count:empty { display: none; }
button.more { display: block; width: 100%; margin-top: 24px; }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toggle { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); min-height: 32px; }
.toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 26px; }
.feed li.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.home { position: relative; }
.home a { display: block; color: inherit; text-decoration: none; }
.heart { position: absolute; z-index: 3; top: 6px; right: 6px; display: grid; place-items: center; width: 44px; height: 44px;
  padding: 0; border: 0; background: transparent; }
.heart svg { width: 28px; height: 28px; fill: rgba(20, 35, 59, .35); stroke: #fff; stroke-width: 1.8; stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(20, 35, 59, .3)); }
.heart[aria-pressed="true"] svg { fill: var(--accent); }
.home.dim { opacity: .45; }
.ph { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--radius); background: var(--soft); }
.ph img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.tint0 { background: #ffe7e1; color: #c8392c; }
.tint1 { background: #dff5ec; color: #0c7a54; }
.tint2 { background: #e4edff; color: #2c55b8; }
.tint3 { background: #fff3cf; color: #8a6400; }
.badge { position: absolute; z-index: 2; top: 12px; left: 12px; padding: 4px 11px; border-radius: 999px; background: #fff;
  font-size: 13px; font-weight: 700; box-shadow: 0 1px 4px rgba(20, 35, 59, .16); }
.body { padding-top: 11px; }
.line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.place { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.ago { flex: none; font-size: 13px; color: var(--muted); }
.t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; color: var(--muted); }
.rent { margin-top: 5px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.rent span { font-weight: 500; color: var(--muted); }
.deadline { margin-top: 3px; font-size: 14px; font-weight: 600; color: var(--accent-strong); }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 0 6px; }
footer a { color: inherit; }

/* annonssida */
.back { min-height: 44px; padding: 0 2px; margin-bottom: 4px; border: 0; background: transparent; font-weight: 700; }
#listing .ph:not(.noimg) { aspect-ratio: 4 / 3; }
#listing .home-head { position: relative; }
.detail h2 { margin: 16px 0 2px; font-size: 25px; letter-spacing: -.03em; line-height: 1.15; }
.detail .addr { margin: 0; color: var(--muted); }
.detail .rent { margin-top: 10px; font-size: 23px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin: 20px 0 0; padding: 18px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { min-width: 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; }
.gone-note { margin: 14px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--soft); font-size: 14px; font-weight: 600; }
.desc { margin: 18px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.site-link { display: flex; align-items: center; justify-content: center; min-height: 52px; margin-top: 22px; padding: 0 18px;
  border-radius: 14px; background: var(--accent-strong); color: #fff; font-weight: 700; text-decoration: none; text-align: center; }
.empty-detail { padding: 44px 16px; text-align: center; color: var(--muted); }

/* bevakning */
.form-title { font-size: 28px; letter-spacing: -.03em; margin: 4px 0 6px; }
fieldset { min-width: 0; margin: 0; padding: 20px 0; border: 0; border-bottom: 1px solid var(--line); }
.field { margin-bottom: 18px; min-width: 0; }
fieldset > .field:last-child, fieldset > .grid3:last-child .field { margin-bottom: 0; }
fieldset { border-top: 0; }
.field label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
details summary { display: flex; justify-content: space-between; gap: 12px; align-items: center;
  min-height: 28px; cursor: pointer; font-weight: 700; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary .muted::after { content: "›"; display: inline-block; margin-left: 8px; transition: transform .15s; }
details[open] summary .muted::after { transform: rotate(90deg); }
.area-group { margin-top: 18px; }
.area-group h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { width: 100%; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid #cdd2d9; border-radius: 12px;
  background: var(--bg); font-size: 16px; font-weight: 500; }
input::placeholder { color: #9aa2ac; }
input[type=date] { -webkit-appearance: none; appearance: none; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 460px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3 .field:nth-child(3):last-child { grid-column: 1 / -1; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 42px; padding: 0 16px; border: 1px solid #cdd2d9; border-radius: 999px;
  background: var(--bg); font-size: 15px; font-weight: 600; }
.date-field { margin-top: 12px; }
.hint-text { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary { min-height: 52px; padding: 0 22px; border: 0; border-radius: 14px; background: var(--accent-strong);
  color: #fff; font-weight: 700; }
button.ghost { min-height: 52px; padding: 0 16px; border: 1px solid #cdd2d9; border-radius: 14px;
  background: var(--bg); font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
#btn-favs-back { display: none; }
@media (min-width: 900px) { #btn-favs-back { display: block; } }
.savebar { position: sticky; bottom: calc(69px + env(safe-area-inset-bottom)); z-index: 3; padding: 12px 0; background: var(--bg); }
.actions { display: flex; gap: 8px; }
.actions .primary { flex: 1; }
.msg { margin: 0; font-size: 14px; color: var(--muted); }
.msg:not(:empty) { margin-bottom: 8px; }

/* flikar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 16px calc(6px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.tabs button { display: grid; justify-items: center; gap: 1px; min-height: 54px; border: 0; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--accent-strong); }

/* dator: bevakning till vänster, annonser i rutnät */
@media (min-width: 900px) {
  .top { padding: 22px 40px 16px; }
  main { max-width: 1240px; display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 48px; align-items: start;
    padding: 4px 40px 48px; }
  #filters { display: block !important; order: -1; }
  body:not([data-view="favs"]):not([data-view="listing"]) #view-feed { display: block !important; }
  .top-favs { display: block; min-height: 34px; padding: 0 14px; border: 1px solid #cdd2d9; border-radius: 999px;
    background: var(--bg); font-size: 14px; font-weight: 600; }
  .tabs, .summary { display: none; }
  .pills { margin: 0 0 24px; padding: 2px 0; flex-wrap: wrap; overflow: visible; }
  .savebar { bottom: 0; }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 .field:nth-child(3):last-child { grid-column: 1 / -1; }
  .feed { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 30px 22px; }
}
