:root {
  color-scheme: light;
  --ink: #221d2e;
  --muted: #7d7789;
  --purple: #7740ca;
  --purple-dark: #5d2aaf;
  --pale: #f2ebfd;
  --background: #f8f7fa;
  --line: #e8e4ee;
  --white: #fff;
  --gold: #945b00;
  --gold-pale: #ffefbb;
  --danger: #bd2c39;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--background); color: var(--ink); }
body { -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button, input { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .38; }
input { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
.visually-hidden { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.loading-screen, .privacy-cover {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center;
  gap: 14px; background: var(--background); padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}
.loading-screen img, .privacy-cover img { filter: drop-shadow(0 14px 24px rgba(91, 43, 165, .2)); }
.loading-screen strong, .privacy-cover strong { font-size: 22px; letter-spacing: .02em; }
.loading-screen span { color: var(--muted); font-size: 14px; }
.privacy-cover { background: #ede9f3; }

.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--background); }
.app-header {
  padding: calc(13px + var(--safe-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 16px; background: rgba(248, 247, 250, .96); border-bottom: 1px solid rgba(232, 228, 238, .82);
}
.brand { flex: 1; min-width: 0; }
.brand-line { display: flex; align-items: baseline; gap: 9px; }
.brand h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; }
.brand-line span { color: var(--muted); font-size: 13px; font-weight: 500; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.data-status {
  display: flex; align-items: center; gap: 7px; flex: none; min-height: 38px; padding: 0 13px; border-radius: 20px;
  background: var(--pale); color: var(--purple-dark); font-weight: 650; font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #32a85a; box-shadow: 0 0 0 3px rgba(50, 168, 90, .13); }
.data-status.empty .status-dot { background: #d58b19; box-shadow: 0 0 0 3px rgba(213, 139, 25, .13); }

.main-area { min-height: 0; overflow: hidden; }
.content-view, .tab-panel { height: 100%; }
.no-data-view { height: 100%; overflow: auto; display: grid; place-items: center; padding: 30px 20px; }
.no-data-card { width: min(520px, 100%); text-align: center; background: var(--white); border: 1px solid var(--line); border-radius: 26px; padding: 38px 32px 30px; box-shadow: 0 18px 50px rgba(52, 34, 81, .07); }
.no-data-card img { margin-bottom: 10px; }
.no-data-card h2 { margin: 0; font-size: 22px; }
.no-data-card p { margin: 14px auto 24px; max-width: 420px; color: var(--muted); font-size: 14px; line-height: 1.75; }
.readiness { margin-top: 17px; color: var(--muted); font-size: 12px; }
.readiness.ready { color: #247a3c; }

.primary-button, .secondary-button, .danger-button {
  min-height: 46px; padding: 0 18px; border-radius: 13px; font-weight: 650; font-size: 14px;
}
.primary-button { color: white; background: linear-gradient(135deg, #8752d6, var(--purple)); box-shadow: 0 8px 18px rgba(119, 64, 202, .2); }
.secondary-button { background: var(--white); border: 1px solid var(--line); }
.danger-button { color: white; background: var(--danger); }
.compact { min-height: 38px; padding: 0 13px; font-size: 12px; }

.map-panel { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: 0 16px 8px; overflow: hidden; }
.selected-card { min-height: 104px; margin-top: 1px; padding: 14px 16px; background: var(--white); border: 1px solid var(--line); border-radius: 18px; }
.selected-title-row { display: flex; align-items: center; gap: 10px; }
.selected-title-row h2 { flex: 1; margin: 0; font-size: 17px; line-height: 1.35; }
.selected-card p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.selected-card .selected-hint { margin-top: 10px; font-size: 13px; }
.selected-count { color: var(--purple) !important; font-size: 11px !important; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
.metric { min-width: 0; }
.metric strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.metric:last-child strong { color: var(--purple); }
.metric span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.map-toolbar { display: flex; align-items: center; gap: 10px; min-height: 55px; padding: 8px 2px; }
.legend { flex: 1; color: var(--purple); font-size: 12px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 9px; height: 9px; margin-right: 3px; border-radius: 50%; background: #9e45da; }
.legend-star { color: #f0b900; -webkit-text-stroke: 1px #532170; }
.legend-border { display: inline-block; width: 11px; height: 9px; margin-right: 3px; border: 2px solid #0f6ef4; vertical-align: -1px; }
.map-viewport { position: relative; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #f6f5f9; touch-action: none; }
.map-stage { position: absolute; width: 4320px; height: 3576px; transform-origin: 0 0; will-change: transform; }
.map-stage > img { position: absolute; inset: 0; width: 4320px; height: 3576px; pointer-events: none; -webkit-user-drag: none; }
.map-markers { position: absolute; inset: 0; }
.map-marker { position: absolute; min-width: 4px; min-height: 4px; padding: 0; background: #9e45da; border: 0; border-radius: 0; color: #ffd54f; overflow: visible; }
.map-marker.selected { outline: max(3px, var(--marker-outline, 4px)) solid #0f6ef4; outline-offset: 0; z-index: 2; }
.map-marker .star { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -52%); font-size: min(18px, 80%); line-height: 1; color: #ffd54f; filter: drop-shadow(0 0 1px #532170); }
.zoom-controls { position: absolute; right: 11px; bottom: 13px; z-index: 4; display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 6px 16px rgba(35, 25, 48, .14); }
.zoom-controls button { width: 47px; height: 46px; padding: 0; background: white; border-bottom: 1px solid var(--line); font-size: 23px; font-weight: 500; }
.zoom-controls button:last-child { border-bottom: 0; font-size: 12px; font-weight: 650; }
.gesture-hint { margin: 7px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

.list-panel { overflow: auto; padding: 0 16px 18px; -webkit-overflow-scrolling: touch; }
.search-box { min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 0 14px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.search-box > span { color: var(--muted); font-size: 24px; transform: rotate(-18deg); }
.search-box input { width: 100%; height: 46px; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.list-controls { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; }
.list-controls button:last-child { margin-left: auto; }
.filter-summary, .count-label { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.filter-summary { padding: 0 2px 7px; }
.count-label { padding: 1px 2px 10px; font-size: 12px; }
.property-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.property-card { position: relative; padding: 15px 16px; background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 3px 10px rgba(38, 24, 56, .025); }
.property-card:active { background: #faf7ff; }
.property-heading { display: flex; align-items: flex-start; gap: 8px; }
.property-heading h3 { flex: 1; min-width: 0; margin: 0; font-size: 16px; line-height: 1.4; }
.property-heading .arrow { color: var(--muted); font-size: 24px; line-height: 1; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 9px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.badge.top { color: white; background: var(--purple); }
.badge.layout { color: var(--gold); background: var(--gold-pale); }
.badge.normal { color: var(--muted); background: #efedf2; }
.property-meta { margin: 6px 0 13px; color: var(--purple); font-size: 11px; }
.empty-results { padding: 50px 20px; text-align: center; }
.empty-results h3 { margin: 0; font-size: 18px; }
.empty-results p { margin: 12px 0 20px; color: var(--muted); font-size: 13px; }

.bottom-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: calc(66px + var(--safe-bottom)); padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + var(--safe-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.nav-button { display: grid; place-content: center; justify-items: center; gap: 4px; border-radius: 14px; background: white; color: var(--muted); font-size: 11px; font-weight: 550; }
.nav-button.active { background: var(--pale); color: var(--purple); font-weight: 700; }
.nav-icon { position: relative; display: block; width: 23px; height: 22px; }
.map-icon::before { content: ""; position: absolute; inset: 1px 2px 3px; border: 2px solid currentColor; border-radius: 4px; transform: skewY(-8deg); }
.map-icon::after { content: ""; position: absolute; left: 10px; top: 3px; width: 2px; height: 16px; background: currentColor; transform: rotate(8deg); }
.list-icon::before { content: ""; position: absolute; inset: 1px 1px; border: 2px solid currentColor; border-radius: 4px; }
.list-icon::after { content: ""; position: absolute; left: 6px; right: 5px; top: 7px; height: 2px; background: currentColor; box-shadow: 0 6px 0 currentColor; }

.modal-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: max(16px, var(--safe-top)) 14px max(14px, var(--safe-bottom)); background: rgba(24, 18, 31, .42); -webkit-backdrop-filter: blur(9px); backdrop-filter: blur(9px); }
.modal-card { position: relative; width: min(620px, 100%); max-height: calc(100dvh - 30px - var(--safe-top) - var(--safe-bottom)); overflow: auto; border-radius: 24px; background: white; padding: 27px 24px 23px; box-shadow: 0 24px 80px rgba(28, 17, 43, .25); }
.modal-card h2 { margin: 0 40px 12px 0; font-size: 22px; }
.modal-card > p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal-close { position: absolute; right: 15px; top: 14px; width: 38px; height: 38px; border-radius: 50%; background: #f2eff5; color: var(--muted); font-size: 25px; }
.password-card { text-align: center; }
.password-card h2 { margin-right: 0; }
.secure-symbol { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 13px; border-radius: 18px; color: white; background: var(--purple); font-size: 33px; }
.password-field { display: block; margin-top: 20px; text-align: left; }
.password-field span { display: block; margin: 0 0 7px 3px; color: var(--muted); font-size: 12px; }
.password-field input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; outline: 0; font-size: 18px; }
.password-field input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(119, 64, 202, .12); }
.show-password { display: flex; align-items: center; gap: 7px; margin: 12px 2px; color: var(--muted); font-size: 12px; text-align: left; }
.field-error { min-height: 20px; color: var(--danger); font-size: 12px; }
.password-card .primary-button { width: 100%; margin-top: 5px; }
.progress-card { text-align: center; }
.progress-card h2 { margin-right: 0; }
.progress-ring { width: 55px; height: 55px; margin: 2px auto 18px; border: 5px solid var(--pale); border-top-color: var(--purple); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { height: 8px; overflow: hidden; margin: 18px 0 13px; border-radius: 10px; background: var(--pale); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--purple); transition: width .2s ease; }
.progress-card small { color: var(--muted); }
.data-info { margin: 20px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; }
.data-info div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.data-info div:last-child { border-bottom: 0; }
.data-info span { color: var(--muted); }
.data-card .primary-button, .data-card .danger-button { width: 100%; margin-top: 10px; }
.local-only-note { text-align: center; font-size: 11px !important; }

.filter-card { height: min(820px, calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom))); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; overflow: hidden; }
.sheet-header { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; min-height: 62px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { margin: 0; text-align: center; font-size: 18px; }
.sheet-header button { height: 44px; background: transparent; color: var(--purple); font-weight: 650; }
.sheet-header button:first-child { color: var(--muted); text-align: left; }
.filter-form { overflow: auto; padding: 4px 22px 25px; }
.filter-section { padding: 20px 0 0; }
.filter-section h3 { margin: 0 0 5px; font-size: 17px; }
.filter-section > p { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; display: flex; align-items: center; justify-content: center; min-height: 43px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--background); font-size: 12px; text-align: center; }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--purple); background: var(--pale); color: var(--purple); font-weight: 700; }
.toggle-choice { justify-content: space-between; padding: 0 14px; }
.toggle { width: 42px; height: 25px; padding: 3px; border-radius: 20px; background: #d7d2dd; transition: .2s; }
.toggle::after { content: ""; display: block; width: 19px; height: 19px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s; }
.choice:has(input:checked) .toggle { background: var(--purple); }
.choice:has(input:checked) .toggle::after { transform: translateX(17px); }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 9px; }
.range-row input { min-width: 0; width: 100%; height: 45px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: var(--background); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: 10px; padding: 3px; border-radius: 12px; background: #efecf2; }
.segmented .choice { min-height: 36px; border: 0; background: transparent; }
.segmented .choice:has(input:checked) { background: white; box-shadow: 0 2px 6px rgba(42, 29, 57, .08); }
.filter-error { min-height: 18px; margin-top: 8px; color: var(--danger); font-size: 11px; }
.filter-footer { padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: white; }
.filter-footer button { width: 100%; }
.sort-options { display: grid; gap: 4px; margin-top: 14px; }
.sort-options button { min-height: 47px; padding: 0 12px; border-radius: 11px; background: transparent; text-align: left; }
.sort-options button.selected { color: var(--purple); background: var(--pale); font-weight: 700; }
.locate-card { height: min(780px, calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom))); display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 12px; overflow: hidden; }
.locate-list { overflow: auto; border-top: 1px solid var(--line); }
.locate-list button { display: flex; justify-content: space-between; width: 100%; min-height: 52px; padding: 10px 4px; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.locate-list small { color: var(--muted); }

.detail-page { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--background); }
.detail-header { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; min-height: calc(58px + var(--safe-top)); padding: var(--safe-top) max(13px, env(safe-area-inset-right)) 0 max(13px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: rgba(248, 247, 250, .97); }
.detail-header h2 { margin: 0; text-align: center; font-size: 17px; }
.detail-header button { height: 48px; padding: 0; background: transparent; color: var(--purple); font-weight: 650; }
.detail-header button:first-child { text-align: left; }
.detail-header button:last-child { text-align: right; }
.detail-content { overflow: auto; padding: 20px max(18px, env(safe-area-inset-right)) calc(30px + var(--safe-bottom)) max(18px, env(safe-area-inset-left)); }
.detail-inner { width: min(760px, 100%); margin: 0 auto; }
.detail-kicker { margin: 0 0 7px; color: var(--purple); font-size: 12px; font-weight: 650; }
.detail-name { margin: 0; font-size: 25px; line-height: 1.3; }
.detail-id { margin: 7px 0 20px; color: var(--muted); font-size: 12px; }
.price-panel { display: flex; align-items: baseline; gap: 7px; margin-bottom: 15px; padding: 17px 18px; border-radius: 18px; color: white; background: linear-gradient(135deg, #8550d5, #6530b6); }
.price-panel strong { font-size: 29px; }
.price-panel span { font-size: 12px; opacity: .86; }
.detail-section { margin-top: 17px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.detail-section h3 { margin: 0 0 13px; font-size: 16px; }
.detail-description { margin: 0; color: #4f495a; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.photo-thumb { position: relative; aspect-ratio: 3 / 2; overflow: hidden; padding: 0; border-radius: 13px; background: #ece9f0; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb span { position: absolute; right: 7px; bottom: 7px; padding: 4px 7px; border-radius: 9px; color: white; background: rgba(20, 15, 27, .72); font-size: 10px; }
.no-photos { display: grid; place-content: center; min-height: 120px; border-radius: 13px; color: var(--muted); background: var(--background); font-size: 13px; }
.source-note { margin: 17px 3px 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

.photo-viewer { position: fixed; inset: 0; z-index: 70; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #121017; color: white; }
.photo-viewer header { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; min-height: calc(62px + var(--safe-top)); padding: var(--safe-top) max(15px, env(safe-area-inset-right)) 0 max(15px, env(safe-area-inset-left)); }
.photo-viewer header button { height: 48px; padding: 0; color: white; background: transparent; text-align: left; }
.photo-viewer header span { text-align: center; font-size: 14px; }
.photo-viewer header span:last-child { color: #bbb7c1; font-size: 12px; text-align: right; }
.photo-stage { position: relative; overflow: hidden; touch-action: none; }
.photo-stage img { position: absolute; top: 50%; left: 50%; max-width: none; max-height: none; transform-origin: center; will-change: transform; -webkit-user-drag: none; }
.photo-viewer footer { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px max(20px, env(safe-area-inset-right)) calc(18px + var(--safe-bottom)) max(20px, env(safe-area-inset-left)); }
.photo-viewer footer button { min-height: 48px; border: 1px solid #39343f; border-radius: 13px; color: white; background: #211e27; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }

.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); z-index: 200; max-width: calc(100% - 40px); transform: translateX(-50%); padding: 11px 16px; border-radius: 12px; color: white; background: rgba(32, 27, 39, .94); box-shadow: 0 8px 25px rgba(0,0,0,.2); font-size: 13px; text-align: center; }

@media (min-width: 760px) {
  .app-header { padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
  .map-panel, .list-panel { padding-left: 24px; padding-right: 24px; }
  .property-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selected-card { padding-left: 20px; padding-right: 20px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal-layer { place-items: center; }
  .filter-card, .locate-card { height: min(840px, calc(100dvh - 60px)); }
}

@media (orientation: landscape) and (min-width: 900px) {
  .brand h1 { font-size: 24px; }
  .app-header { padding-top: calc(9px + var(--safe-top)); padding-bottom: 9px; }
  .selected-card { min-height: 92px; }
  .map-toolbar { min-height: 48px; }
  .map-panel { padding-bottom: 5px; }
  .gesture-hint { margin-top: 4px; }
  .bottom-nav { min-height: calc(58px + var(--safe-bottom)); padding-top: 5px; padding-bottom: calc(5px + var(--safe-bottom)); }
  .detail-content { padding-top: 18px; }
}

@media (max-width: 390px) {
  .brand h1 { font-size: 23px; }
  .legend { font-size: 10px; }
  .selected-card { min-height: 101px; }
  .metrics strong { font-size: 14px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
