/* Shared light/dark tokens; data-theme pins the user's choice. */
:root {
  color-scheme: light dark;
  --bg:        light-dark(#f4f6f9, #0b1120);
  --card:      light-dark(#fff,    #131c2e);
  --text:      light-dark(#1c2430, #e6edf6);
  --soft:      light-dark(#56606d, #a8b3c4);
  --mute:      light-dark(#8a93a0, #7f8b9e);
  --faint:     light-dark(#c3cbd5, #55627a);
  --border:    light-dark(#e3e8ef, #24314a);
  --rule:      light-dark(#eef1f5, #1e2942);
  --row-alt:   light-dark(#f9f9f9, #111a2b);
  --row-hover: light-dark(#f0f3f8, #1a2439);
  --tile:      light-dark(#f7f9fc, #0e1626);
  --field-bg:  light-dark(#fff,    #0e1626);
  --field-br:  light-dark(#d3dae3, #35435e);
  --blue:      light-dark(#1667d1, #5b9bf5);
  --blue-hover:light-dark(#1257b3, #7db0f8);
  --chip-bg:   light-dark(#eaf1fb, #17263f);
  --tag-br:    light-dark(#cfe0f7, #2c4770);
  --ring:      light-dark(rgba(22,103,209,.15), rgba(91,155,245,.25));
  --shadow:    light-dark(rgba(16,24,40,.14), rgba(0,0,0,.5));
  --shadow-hover: light-dark(rgba(20,40,80,.08), rgba(0,0,0,.45));
  --ok:        light-dark(#2f7d54, #6ee7a8);
  --ok-bg:     light-dark(#e8f0ea, #16301f);
  --tour:      light-dark(#6035c9, #b39cf5);
  --tour-bg:   light-dark(#ede7fb, #2a1f4a);
  --pin-br:    light-dark(rgba(28,36,48,.25), rgba(230,237,246,.3));
}
:root[data-theme="light"] { color-scheme: only light; }
:root[data-theme="dark"]  { color-scheme: only dark; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 500; }
nav { display: flex; align-items: center; gap: 14px; padding: 8px 14px; height: 56px; }
.navlink { color: var(--soft); font-weight: 500; }
.spacer { flex: 1; }
.tabs { display: flex; align-items: center; gap: 14px; min-width: 0;
        overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
nav > :not(.tabs, .spacer) { flex: 0 0 auto; }
.count { color: var(--mute); font-size: 13px; white-space: nowrap; }
.crawl { display: flex; position: relative; }
button {
  background: var(--blue); color: #fff; border: 0; border-radius: 7px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}
.crawl button { font-size: 17px; line-height: 1; padding: 7px 11px; }
button:hover { background: var(--blue-hover); }

.crawl.busy button { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.crawl-status { position: relative; display: flex; align-items: center; gap: 5px; font-size: 13px; max-width: 42vw; min-width: 0; }
#crawl-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crawl-status.busy { color: var(--mute); }
.crawl-status.done { color: var(--ok); font-weight: 600; }

.crawl-more { background: none; color: inherit; border: 0; padding: 0 2px; font-size: 11px; line-height: 1; }
.crawl-more:hover { background: none; opacity: .6; }
.crawl-detail {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 600;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 6px 20px var(--shadow); padding: 10px 12px;
  color: var(--text); font-weight: 400; white-space: nowrap;
  max-width: 92vw; overflow-x: auto;
}
.crawl-detail table { border-collapse: collapse; }
.crawl-detail th, .crawl-detail td { padding: 3px 9px; text-align: right; }
.crawl-detail th { color: var(--mute); font-weight: 500; }
.crawl-detail th:first-child, .crawl-detail td:first-child { text-align: left; }
.crawl-detail tr + tr td { border-top: 1px solid var(--row-hover); }
.crawl-detail p { margin: 8px 2px 0; color: var(--mute); font-size: 12px; }

.crawl-sites {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 600;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 6px 20px var(--shadow); padding: 12px;
  width: 260px; max-width: 92vw;
}
.crawl-go { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.crawl .crawl-go button { font-size: 14px; padding: 6px 14px; }
.crawl .plain {
  background: none; color: var(--soft); font-size: 13px; font-weight: 500; padding: 4px 0;
}
.crawl .plain:hover { background: none; color: var(--blue); }

main { padding: 16px; }

@media (max-width: 560px) {
  nav { gap: 10px; padding: 8px 10px; }
  .tabs { gap: 12px; }
  .count { font-size: 12px; }
  .count .unit { display: none; }
  .count.scan { display: none; }
  #crawl-text { display: none; }
  .crawl-status { max-width: none; }
  .crawl-more { font-size: 13px; padding: 4px 6px; }
  .crawl-detail { position: fixed; top: 58px; left: 8px; right: 8px; max-width: none; }
  .crawl-detail p { white-space: normal; }
  main { padding: 12px; }
  .detail { padding: 14px; }
  .history { display: block; overflow-x: auto; max-width: 100%; }
}

form.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
form.filters select { padding: 7px 10px; border: 1px solid var(--field-br); border-radius: 7px;
                      font-size: 14px; background: var(--field-bg); color: var(--text); }

.filter-layout { display: flex; gap: 12px; align-items: flex-start; }
.filter-content { flex: 1; min-width: 0; }
.filter-content.loading { opacity: .5; transition: opacity .12s; }
.filters-panel {
  flex: 0 0 272px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
}
.filters-panel .fhead { display: flex; align-items: baseline; justify-content: flex-end; }
.filters-panel .reset { font-size: 12px; color: var(--soft); text-decoration: none; }
.filters-panel .reset:hover { text-decoration: underline; }

.filters-panel form { display: flex; flex-direction: column; gap: 18px; }
.filters-panel .fgroup { display: flex; flex-direction: column; gap: 16px;
                         padding-bottom: 18px; border-bottom: 1px solid var(--rule); }
.filters-panel .fgroup:last-of-type { padding-bottom: 0; border-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 11px; font-weight: 700; letter-spacing: .05em;
                 text-transform: uppercase; color: var(--mute); }
.filters-panel input[type=text], .filters-panel input[type=number],
.filters-panel input[type=date], .filters-panel select:not([multiple]) {
  width: 100%; padding: 8px 10px; border: 1px solid var(--field-br); border-radius: 8px;
  font-size: 14px; background: var(--field-bg);
}
.filters-panel input[type=date] { min-width: 0; }
.filters-panel input:focus, .filters-panel .ts-control.focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block; padding: 5px 11px; border: 1px solid var(--field-br);
  border-radius: 999px; font-size: 13px; color: var(--soft); background: var(--field-bg);
  user-select: none; transition: background .12s, border-color .12s, color .12s;
}
.chip input:checked + span { background: var(--chip-bg); border-color: var(--blue); color: var(--blue); font-weight: 600; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }

.range { display: flex; align-items: center; gap: 8px; }
.range input { flex: 1; min-width: 0; }
.range .dash { color: var(--faint); }

.filters-panel .ts-control { border-radius: 8px; border-color: var(--field-br); font-size: 14px; padding: 4px 6px;
                             background: var(--field-bg); color: var(--text); }
.filters-panel .ts-control .item { background: var(--chip-bg); color: var(--blue); border: 1px solid var(--tag-br); border-radius: 6px; }
.filters-panel .ts-wrapper.input-active .ts-control { background: var(--field-bg); }
.ts-dropdown { z-index: 1000; background: var(--card); color: var(--text); border-color: var(--field-br); }
.ts-dropdown .active { background: var(--chip-bg); color: var(--blue); }
.ts-dropdown .optgroup-header { background: var(--card); color: var(--mute); }

@media (max-width: 760px) {
  .filter-layout { flex-direction: column; align-items: stretch; }
  .filters-panel { position: static; flex-basis: auto; max-height: none; }
  .filters-panel form { flex-direction: row; flex-wrap: nowrap; align-items: baseline; gap: 12px; }
  .filters-panel details.more { order: 1; flex: 1 1 0; min-width: 0; }
  .filters-panel .fhead { order: 2; flex: 0 0 auto; }
}

.filters-panel details.more[open] { display: flex; flex-direction: column; gap: 18px; }
.filters-panel details.more > summary {
  cursor: pointer; list-style: none; font-size: 13px; font-weight: 600; color: var(--blue);
}
.filters-panel details.more > summary::-webkit-details-marker { display: none; }
.filters-panel details.more > summary::after { content: " ▾"; }
.filters-panel details.more[open] > summary::after { content: " ▴"; }
@media (min-width: 761px) { .filters-panel details.more > summary { display: none; } }

.price { font-weight: 700; font-size: 17px; }
.price .unit { font-weight: 500; font-size: 12px; color: var(--mute); }
.badge { background: var(--chip-bg); color: var(--blue); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge.src { background: var(--ok-bg); color: var(--ok); }
.badge.tour { background: var(--tour-bg); color: var(--tour); }

.empty { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 40px; text-align: center; color: var(--soft); }

pre { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
      margin: 0; overflow: auto; font-size: 12.5px; line-height: 1.5; }

.detail { max-width: 900px; margin: 0 auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.back { display: inline-block; margin-bottom: 10px; color: var(--soft); }
.detail h1 { margin: 4px 0; font-size: 22px; }
.price.big { font-size: 24px; margin-bottom: 14px; }
.detail .tour { display: inline-block; margin: 2px 0 14px; padding: 9px 16px; border-radius: 9px;
                background: #6035c9; color: #fff; font-weight: 700; font-size: 14px; }
.detail .tour:hover { background: #4d2aa8; text-decoration: none; }
/* Four thumbnails per row; side buttons scroll the strip. */
.gallery { display: flex; align-items: center; gap: 6px; margin: 14px 0; }
.gal-strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gal-strip::-webkit-scrollbar { display: none; }
.gal-strip img {
  flex: 0 0 calc(25% - 6px); min-width: 0; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 8px; scroll-snap-align: start; cursor: zoom-in;
}
.gal-nav {
  flex: none; width: 30px; height: 46px; font-size: 22px; line-height: 1; cursor: pointer;
  color: var(--soft); background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.gal-nav:hover { color: var(--text); background: var(--row-hover); }
.lightbox {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0, 0, 0, .85); cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
@media (max-width: 700px) { .gal-strip img { flex-basis: calc(50% - 4px); } }
.detail h2 { font-size: 15px; margin: 22px 0 6px; }
.detail h2 small { font-weight: 500; color: var(--mute); }
.spec { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 28px; margin: 6px 0 4px; }
.spec > div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
            padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.spec dt { color: var(--mute); white-space: nowrap; }
.spec dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.spec dd > div + div { margin-top: 2px; }
.spec .soft { color: var(--mute); font-weight: 500; }
/* Keep change-log dates in a narrow column beside the text. */
.spec.log { grid-template-columns: 1fr; }
.spec.log > div { justify-content: flex-start; }
.spec.log dt { flex: none; width: 120px; }
.spec.log dd { flex: 1; text-align: left; }
.history { border-collapse: collapse; margin: 8px 0 16px; }
.history th, .history td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; font-size: 14px; }
.source { margin-top: 18px; }

.feed-day { margin-bottom: 26px; max-width: 880px; }
.feed-more { max-width: 880px; padding: 14px; text-align: center; font-size: 13px; color: var(--mute); }
.feed-date { font-size: 16px; margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px;
             border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.feed-counts { font-size: 12px; font-weight: 600; display: flex; gap: 10px; }
.feed-counts .new { color: var(--ok); }
.feed-counts .rep { color: var(--mute); }
.feed-list { display: flex; flex-direction: column; gap: 7px; }
.feed-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px;
  color: inherit; transition: box-shadow .15s, border-color .15s;
}
.feed-item:hover { border-color: var(--field-br); box-shadow: 0 3px 12px var(--shadow-hover); text-decoration: none; }
.fi-thumb { flex: 0 0 96px; width: 96px; height: 70px; border-radius: 7px; overflow: hidden; background: var(--rule); }
.fi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fi-thumb .noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--faint); font-size: 11px; }
.fi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.fi-title { font-weight: 600; font-size: 14px; line-height: 1.3; color: var(--text);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--soft); font-size: 12.5px; }
.fi-meta .facts { display: inline-flex; flex-wrap: wrap; gap: 6px; color: var(--mute); font-size: 12px; }
.fi-meta .facts span + span::before { content: "·"; color: var(--faint); margin-right: 6px; }
.fi-price { flex: 0 0 auto; text-align: right; padding-left: 8px; }
.fi-price .price { font-weight: 700; font-size: 15px; white-space: nowrap; }
.fi-price .unit { font-weight: 500; font-size: 11px; color: var(--mute); }
@media (max-width: 560px) {
  .fi-thumb { flex-basis: 72px; width: 72px; height: 56px; }
  .fi-price .unit { display: none; }
}

.reposts { margin-top: 12px; }
.reposts summary { cursor: pointer; color: var(--mute); font-size: 13px; font-weight: 600; padding: 2px 0; }
.reposts summary:hover { color: var(--soft); }
.repost-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.repost-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
                  padding: 6px 8px; border-radius: 6px; }
.repost-list li:hover { background: var(--rule); }
.repost-list .rp-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.repost-list .rp-price { font-weight: 700; font-size: 14px; white-space: nowrap; }
.repost-list .rp-title { color: var(--soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repost-list .rp-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
                        color: var(--mute); font-size: 12px; margin-left: auto; }

.price-pin { width: auto !important; height: auto !important; }
.price-pin .pill {
  position: absolute; top: 0; left: 0; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 3px 8px; border-radius: 11px; background: var(--card); color: var(--text);
  border: 1px solid var(--pin-br); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  font: 700 11.5px/1.2 system-ui, -apple-system, sans-serif;
}
.price-pin .pill .l { display: block; white-space: nowrap; }
.price-pin.unplaced .pill { color: var(--mute); border-style: dashed; }
.leaflet-container a.leaflet-popup-close-button {
  font: 24px/26px system-ui, -apple-system, sans-serif; width: 30px; height: 30px;
  padding: 4px 6px 0 0; color: var(--soft);
}
.pin-pop { min-width: 230px; max-width: 260px; }
.pin-pop .h { font-size: 14px; font-weight: 700; color: var(--text); }
.pin-pop .price { font-size: 15px; font-weight: 700; color: var(--text); margin: 2px 0 6px; }
.pin-pop img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; }
.pin-pop .kv { font-size: 12px; color: var(--soft); }
.pin-pop .rows { margin-top: 8px; border-top: 1px solid var(--rule); }
.pin-pop .row { display: flex; gap: 10px; align-items: baseline;
                padding: 4px 0; border-bottom: 1px solid var(--rule); }
.pin-pop .row .k { flex: 0 0 auto; font-size: 11px; text-transform: uppercase;
                   letter-spacing: .04em; color: var(--mute); }
.pin-pop .row .v { flex: 1; min-width: 0; text-align: right; font-size: 12px;
                   color: var(--text); }
.pin-pop a { display: inline-block; margin-top: 8px; }

.proj-wrap { display: flex; gap: 12px; align-items: flex-start; }
.proj-side { flex: 0 0 46%; max-width: 520px; min-width: 0; }
.proj-wrap #map { flex: 1; position: sticky; top: 12px;
                  height: calc(100dvh - 84px); border-radius: 10px; }
.proj-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.proj-head input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--field-br);
                   background: var(--field-bg); color: var(--text);
                   border-radius: 8px; font-size: 14px; }
.proj-head input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring); }
.proj-list { display: flex; flex-direction: column; gap: 7px; }
.proj-list .feed-item[hidden] { display: none; }
.proj-list .fi-title a { color: inherit; }
.proj-list .fi-price .price { font-size: 14px; white-space: normal; }
.badge.fresh { background: var(--ok-bg); color: var(--ok); margin-left: 6px; }
@media (max-width: 760px) {
  .proj-wrap { flex-direction: column; align-items: stretch; }
  .proj-side { flex: none; max-width: none; }
  .proj-wrap #map { position: static; flex: none; height: 60dvh; min-height: 320px; order: -1; }
}

.muted { color: var(--mute); font-size: 13px; margin: 4px 2px 12px; }

#theme {
  background: none; color: var(--mute); border: 0; padding: 4px;
  display: flex; align-items: center; border-radius: 7px;
}
#theme:hover { background: none; color: var(--text); }

/* Prefix these rules because Tabulator's stylesheet loads after this file. */
body .tabulator {
  background: var(--card); color: var(--text); font-size: 13px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
body .tabulator .tabulator-tableholder { background: var(--card); }
body .tabulator .tabulator-tableholder:focus { outline: none; }
body .tabulator .tabulator-header {
  background: var(--tile); border-bottom: 1px solid var(--border);
}
body .tabulator .tabulator-header .tabulator-col {
  background: none; border-right: 1px solid var(--rule);
}
body .tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 7px 9px; }
body .tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  color: var(--soft); font-size: 12px; font-weight: 600;
}
body .tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover { background: var(--row-hover); }
body .tabulator .tabulator-row { background: var(--card); color: var(--text); border-bottom: 1px solid var(--rule); }
body .tabulator .tabulator-row.tabulator-row-even { background: var(--row-alt); }
body .tabulator .tabulator-row:hover,
body .tabulator .tabulator-row.tabulator-selectable:hover { background: var(--row-hover); }
body .tabulator .tabulator-row .tabulator-cell {
  border-right: 1px solid var(--rule); padding: 7px 9px;
}
body .tabulator a { color: var(--blue); }
body .tabulator input, body .tabulator select {
  background: var(--field-bg); color: var(--text); font-size: 12px;
  border: 1px solid var(--field-br); border-radius: 6px; padding: 4px 7px;
}
body .tabulator input:focus, body .tabulator select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring);
}
body .tabulator .tabulator-col .tabulator-arrow {
  border-bottom-color: var(--mute); border-top-color: var(--mute);
}
body .tabulator .tabulator-col[aria-sort="asc"] .tabulator-arrow,
body .tabulator .tabulator-col[aria-sort="desc"] .tabulator-arrow {
  border-bottom-color: var(--blue); border-top-color: var(--blue);
}
body .tabulator .tabulator-footer {
  background: var(--tile); border-top: 1px solid var(--border); padding: 5px 8px;
}
body .tabulator .tabulator-footer .tabulator-paginator label,
body .tabulator .tabulator-footer .tabulator-page-counter { color: var(--soft); font-size: 12px; }
body .tabulator .tabulator-footer .tabulator-page {
  background: var(--field-bg); color: var(--text); font-weight: 500;
  border: 1px solid var(--field-br); border-radius: 7px; padding: 4px 9px; margin: 0 2px;
}
body .tabulator .tabulator-footer .tabulator-page:hover:not(.active):not(:disabled) { background: var(--row-hover); }
body .tabulator .tabulator-footer .tabulator-page.active {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
body .tabulator .tabulator-footer .tabulator-page:disabled { opacity: .45; }
body .tabulator-tooltip {
  background: var(--card); color: var(--text); border-color: var(--border);
  border-radius: 8px; box-shadow: 0 3px 14px var(--shadow);
}
body .tabulator .tabulator-alert .tabulator-alert-msg {
  background: var(--card); color: var(--text); border-color: var(--border);
}

body .leaflet-container { background: var(--bg); }
.leaflet-container .leaflet-tooltip, .leaflet-container .leaflet-popup-content-wrapper,
.leaflet-container .leaflet-popup-tip, .leaflet-container .leaflet-bar a,
.leaflet-container .leaflet-control-attribution {
  background: var(--card); color: var(--text); border-color: var(--border);
}
.leaflet-container .leaflet-popup-content-wrapper { box-shadow: 0 3px 14px var(--shadow); }
.leaflet-container .leaflet-control-attribution a { color: var(--blue); }
