:root {
    --bg: #f5f6f2;
    --surface: #ffffff;
    --surface-subtle: #f8f8f5;
    --line: #deded6;
    --text: #20231f;
    --muted: #666b61;
    --accent: #2f6f5e;
    --accent-strong: #245748;
    --price: #a23a2a;
    --marker-land: #8a5a2b;
    --marker-house: #2f5f9f;
    --marker-mansion-new: #4f8f72;
    --marker-house-new: #637fc0;
    --focus: #b7791f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

.shell {
    width: min(1440px, calc(100vw - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.header-inner {
    min-height: 56px;
    display: flex;
    align-items: center;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
}

.search-workspace,
.detail-page {
    padding: 24px 0 48px;
}

.page-title {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 18px;
}

.page-title h1 {
    margin: 0 0 4px;
    font-size: 28px;
    line-height: 1.2;
}

.page-title p {
    margin: 0;
    color: var(--muted);
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
}

.summary-strip div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 12px;
}

.summary-strip span {
    display: block;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

.workspace-grid {
    display: grid;
    grid-template-columns: 312px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.filter-panel,
.results-panel,
.detail-main,
.similar-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filter-panel {
    position: sticky;
    top: 72px;
    padding: 16px;
}

.filter-block {
    margin-bottom: 14px;
}

.filter-block label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

input:not([type="checkbox"]),
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    padding: 7px 9px;
}

input:not([type="checkbox"]):focus,
select:focus {
    border-color: var(--focus);
    outline: 2px solid rgba(183, 121, 31, 0.16);
}

.range-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.area-row {
    margin-top: 8px;
}

.filter-actions,
.external-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.primary-button,
.secondary-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 8px 12px;
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
}

.primary-button {
    flex: 1;
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    background: var(--surface-subtle);
    border-color: var(--line);
    color: var(--text);
}

.results-panel {
    min-width: 0;
    padding: 0;
}

.results-toolbar {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    color: var(--muted);
}

.results-toolbar strong {
    color: var(--text);
    font-size: 18px;
}

.results-toolbar span {
    margin-left: 10px;
}

.listing-list {
    display: flex;
    flex-direction: column;
}

.listing-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 128px;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.listing-row:hover {
    background: var(--surface-subtle);
}

.listing-title-line {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.listing-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    text-decoration: none;
}

.listing-title:hover {
    color: var(--accent);
}

.listing-price,
.detail-price {
    color: var(--price);
    font-size: 22px;
    font-weight: 800;
    margin-top: 4px;
}

.listing-location {
    color: var(--muted);
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.listing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.listing-meta span {
    background: #eeeeea;
    border-radius: 999px;
    padding: 3px 8px;
    color: #4f554c;
    font-size: 12px;
}

.listing-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.listing-side strong {
    color: var(--text);
}

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--muted);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 16px;
}

.pagination a,
.pagination span {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
    background: #fff;
}

.pagination .current-page {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.page-gap {
    border-color: transparent;
    background: transparent;
}

.breadcrumb {
    display: flex;
    gap: 8px;
    color: var(--muted);
    margin-bottom: 14px;
    font-size: 14px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

.detail-main,
.similar-panel {
    padding: 18px;
}

.detail-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.detail-heading h1 {
    margin: 0 0 6px;
    font-size: 26px;
    line-height: 1.25;
}

.detail-heading p {
    margin: 0;
    color: var(--muted);
}

.fact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 18px 0;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.fact-grid div {
    min-width: 0;
    padding: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.fact-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.fact-grid dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.data-section {
    margin-top: 24px;
}

.data-section h2,
.similar-panel h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    background: var(--surface-subtle);
    color: var(--muted);
    font-size: 12px;
}

tr:last-child td {
    border-bottom: 0;
}

.similar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.similar-item {
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    text-decoration: none;
    background: #fff;
}

.similar-item:hover {
    border-color: var(--accent);
}

.similar-item strong,
.similar-item span,
.similar-item small {
    display: block;
}

.similar-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.similar-item span {
    color: var(--price);
    font-weight: 800;
}

.similar-item small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.map-workspace {
    height: calc(100dvh - 56px);
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    background: #d9d7cf;
    overflow: hidden;
}

.map-filter-panel {
    z-index: 3;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    font-size: 13px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.map-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 9px;
    border-bottom: 1px solid var(--line);
}

.map-title h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
}

.map-title p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.map-form {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.map-filter-panel .filter-block {
    margin-bottom: 12px;
}

.map-filter-panel .filter-block label {
    font-size: 12px;
}

.map-filter-panel input:not([type="checkbox"]),
.map-filter-panel select {
    min-height: 34px;
    font-size: 13px;
    padding: 6px 8px;
}

.filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.filter-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.checkbox-group {
    display: grid;
    gap: 6px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 9px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    font-weight: 700;
}

.filter-block .checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 0;
}

.checkbox-item input {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    padding: 0;
    accent-color: var(--accent);
}

.checkbox-item span {
    display: block;
    line-height: 16px;
}

.compact-checkbox {
    margin-top: 8px;
}

.map-list {
    min-height: 0;
    overflow: auto;
    padding: 8px;
}

.map-list[hidden],
.map-list:empty {
    display: none;
}

.map-selected-item {
    width: 100%;
    display: block;
    margin: 0 0 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-align: left;
}

.map-selected-item strong,
.map-selected-item span,
.map-selected-item small,
.map-selected-item a {
    display: block;
}

.map-selected-item strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-selected-item span {
    color: var(--price);
    font-weight: 800;
    white-space: pre-line;
}

.map-selected-item small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.map-selected-item a {
    width: fit-content;
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 9px;
    background: var(--surface-subtle);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.map-guidance {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    max-width: min(360px, calc(100% - 24px));
    padding: 7px 9px;
    border: 1px solid #e1c65f;
    border-radius: 6px;
    background: rgba(255, 248, 216, 0.94);
    color: #6f5511;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

.map-guidance:empty {
    display: none;
}

.map-error {
    margin: 12px 16px;
    padding: 10px 12px;
    border: 1px solid #f0b7a8;
    border-radius: 8px;
    background: #fff3ef;
    color: #9b2f15;
    font-size: 13px;
    font-weight: 700;
}

.map-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.property-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #f0ede8;
}

.map-marker {
    background: var(--accent);
    min-width: 44px;
    max-width: 86px;
    min-height: 28px;
    padding: 4px 7px;
    border: 2px solid #fff;
    border-radius: 999px 999px 999px 4px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.map-marker.grouped {
    max-width: 180px;
    white-space: pre-line;
    overflow: visible;
    text-overflow: clip;
}

.map-marker.mansion {
    background: var(--accent);
}

.map-marker.land {
    background: var(--marker-land);
}

.map-marker.house {
    background: var(--marker-house);
}

.map-marker.mansion.new {
    background: var(--marker-mansion-new);
}

.map-marker.house.new {
    background: var(--marker-house-new);
}

.map-marker.selected {
    z-index: 4;
    box-shadow: 0 0 0 3px rgba(162, 58, 42, 0.35), 0 2px 8px rgba(0, 0, 0, 0.26);
}

.property-popup {
    min-width: 220px;
    max-width: 300px;
}

.maplibregl-popup-content {
    max-height: calc(100vh - 96px);
    overflow: auto;
}

.property-popup strong,
.property-popup-price,
.property-popup-address {
    display: block;
}

.property-popup strong {
    overflow-wrap: anywhere;
}

.property-popup-price {
    margin-top: 5px;
    color: var(--price);
    font-size: 18px;
    font-weight: 800;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.property-popup-address {
    margin-top: 4px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.property-popup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.property-popup-meta span {
    background: #e9e9e3;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 12px;
}

.property-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.property-popup-actions a {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 9px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.property-popup-list {
    max-height: 220px;
    margin-top: 10px;
    overflow: auto;
    border-top: 1px solid var(--line);
}

.property-popup-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
}

.property-popup-row:hover .property-popup-row-price {
    text-decoration: underline;
}

.property-popup-row-price {
    color: var(--price);
    font-weight: 800;
    white-space: nowrap;
}

.property-popup-row-meta {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.property-popup-more {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.map-attribution {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.14);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.map-attribution a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 980px) {
    .page-title,
    .detail-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .workspace-grid,
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        position: static;
    }

    .fact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: 360px minmax(0, 1fr);
        height: auto;
        min-height: calc(100vh - 56px);
        overflow: visible;
    }

    .map-filter-panel {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--line);
        overflow: visible;
    }

    .map-stage {
        order: 1;
        min-height: 360px;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(100vw - 20px, 1440px);
    }

    .header-inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        padding: 10px 0;
    }

    .listing-row {
        grid-template-columns: 1fr;
    }

    .listing-side {
        align-items: flex-start;
        text-align: left;
        gap: 8px;
    }

    .listing-title-line {
        align-items: flex-start;
        flex-direction: column;
    }

    .listing-title {
        white-space: normal;
    }

    .range-row,
    .filter-row,
    .fact-grid,
    .summary-strip {
        grid-template-columns: 1fr;
    }

}
