:root {
  color-scheme: light;
  --canvas: #f2f6fa;
  --panel: #ffffff;
  --panel-soft: #f5f8fb;
  --ink: #172e44;
  --muted: #5f7284;
  --line: #d3dee8;
  --control-line: #8198a4;
  --route: #2b6fad;
  --route-strong: #1f5688;
  --route-soft: #e4f1fa;
  --route-ink: #ffffff;
  --sun: #9a6500;
  --coral: #e36a4e;
  --coral-ink: #2a1510;
  --location: #f2bd3f;
  --location-ring: #8a5a00;
  --warning: #a54632;
  --map-bg: #e7eff5;
  --control-height: 44px;
  --radius: 8px;
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-family: "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  font-synthesis: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f1923;
  --panel: #162432;
  --panel-soft: #1c2c3b;
  --ink: #edf4fa;
  --muted: #a8b7c5;
  --line: #344a5d;
  --control-line: #5d717d;
  --route: #3374a5;
  --route-strong: #afd7f4;
  --route-soft: #203a50;
  --route-ink: #ffffff;
  --sun: #ffd166;
  --coral: #ff8a6a;
  --coral-ink: #22100b;
  --location: #ffd166;
  --location-ring: #ffd166;
  --warning: #ffad99;
  --map-bg: #101b25;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--canvas); }
body { height: 100svh; margin: 0; overflow: hidden; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { min-width: 0; font: inherit; }
button, summary { cursor: pointer; }
a { color: var(--route-strong); text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 1000; padding: 10px 12px; border: 1px solid var(--line); background: var(--panel); }
.skip-link:focus { top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 28px;
  height: 78px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { flex: 0 0 auto; width: 42px; height: 42px; }
.brand-mark > path:first-child { fill: var(--coral); }
.brand-mark circle { fill: var(--coral-ink); }
.brand-mark .brand-smile { fill: none; stroke: var(--coral-ink); stroke-linecap: round; stroke-width: 2; }
.brand p, .results-heading p, .dialog-kicker, .setup-kicker { margin: 0 0 3px; color: var(--muted); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; }
h1, h2 { font-family: var(--display); }
h1 { margin: 0; font-size: 1.375rem; font-weight: 600; line-height: 1.1; }
.topbar-promise { display: grid; justify-items: center; font-size: .75rem; line-height: 1.45; }
.topbar-promise strong { font-family: var(--display); font-size: .9375rem; font-weight: 600; }
.topbar-promise span { color: var(--muted); }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.text-button, .icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}
.text-button { padding: 7px 9px; font-size: .8125rem; }
.text-button:hover, .icon-button:hover { border-color: var(--line); background: var(--panel-soft); color: var(--route-strong); }
.icon-button { display: grid; place-items: center; width: 42px; border-radius: 50%; font-weight: 700; }
.saved-button span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 3px; border-radius: 999px; background: color-mix(in srgb, var(--coral) 14%, var(--panel)); color: var(--warning); font-size: .6875rem; }

.view-switch { display: none; }
.app-shell { display: grid; grid-template-columns: 410px minmax(0, 1fr); height: calc(100svh - 78px); min-height: 0; }
.sidebar { min-width: 0; height: 100%; overflow: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); background: var(--panel); scrollbar-gutter: stable; }

.filter-panel { padding: 20px 22px 18px; border-bottom: 1px solid var(--line); }
.filter-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; list-style: none; }
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary span:first-child { display: grid; gap: 3px; }
.filter-panel summary small { color: var(--muted); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; }
.filter-panel summary strong { font-family: var(--display); font-size: 1.125rem; font-weight: 600; }
.summary-action { color: var(--muted); font-size: .6875rem; }
.search-field { display: block; margin-top: 14px; }
select, input[type="search"], textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 9px 11px;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}
input[type="search"] { background: var(--panel-soft); }
input[type="search"]::placeholder { color: var(--muted); }
textarea { line-height: 1.55; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 12px; }
.field-grid label > span, .feedback-form label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.distance-field { grid-column: 1 / -1; }
.quick-filters { display: flex; align-items: center; gap: 8px; padding: 12px 0 0; margin: 12px 0 0; border: 0; border-top: 1px solid var(--line); }
.quick-filters legend { float: left; margin-right: 4px; padding: 9px 0 0; color: var(--muted); font-size: .6875rem; }
.quick-filters label { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 5px 10px; border: 1px solid var(--control-line); border-radius: 999px; font-size: .75rem; }
.quick-filters label:has(input:checked) { border-color: var(--route); background: var(--route-soft); color: var(--route-strong); }
.quick-filters input { width: 17px; height: 17px; margin: 0; accent-color: var(--route); }
.filter-actions { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 14px; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 9px 14px;
  border: 1px solid var(--route);
  border-radius: var(--radius);
  font-weight: 600;
}
.primary-button { background: var(--route); color: var(--route-ink); }
.primary-button:hover { background: var(--route-strong); }
html[data-theme="dark"] .primary-button:hover { color: #0f1923; }
.primary-button:disabled { cursor: wait; opacity: .62; }
.secondary-button { background: transparent; color: var(--route-strong); }
.secondary-button:hover { background: var(--route-soft); }
.status { min-height: 17px; margin: 8px 0 0; color: var(--muted); font-size: .6875rem; line-height: 1.45; }

.results-panel { min-width: 0; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 20px 22px 13px; border-bottom: 1px solid var(--line); }
.results-heading h2 { margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.result-count { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.place-list { min-height: 140px; }
.place-card { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) 42px; gap: 10px; padding: 15px 18px 15px 20px; border-bottom: 1px solid var(--line); transition: background-color .14s ease; }
.place-card:hover, .place-card:focus-within, .place-card.is-selected { background: var(--panel-soft); }
.place-card.is-selected { box-shadow: inset 3px 0 0 var(--coral); }
.rank-badge { display: grid; place-items: center; align-self: start; width: 36px; height: 36px; border: 1px solid var(--route); border-radius: 50% 50% 50% 8px; background: var(--route-soft); color: var(--route-strong); font-family: var(--display); font-weight: 700; transform: rotate(-45deg); }
.rank-badge span { transform: rotate(45deg); }
.place-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.place-open:hover .place-name { color: var(--route-strong); text-decoration: underline; text-underline-offset: 4px; }
.place-name { margin: 0; padding-right: 4px; font-size: .9375rem; line-height: 1.45; }
.place-meta { margin: 3px 0 8px; color: var(--muted); font-size: .6875rem; line-height: 1.5; }
.reason-list { display: flex; flex-wrap: wrap; gap: 5px; }
.reason-chip { padding: 3px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); font-size: .625rem; }
.reason-chip:first-child { border-color: color-mix(in srgb, var(--route) 45%, var(--line)); background: var(--route-soft); color: var(--route-strong); }
.favorite-button { display: grid; place-items: center; align-self: start; width: 40px; height: 40px; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.125rem; }
.favorite-button:hover { border-color: var(--line); background: var(--panel); }
.favorite-button[aria-pressed="true"] { color: var(--coral); }
.empty-state { padding: 46px 24px; text-align: center; }
.empty-state h3 { margin: 0 0 7px; font-family: var(--display); font-size: 1.0625rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.6; }
.data-note { margin: 0; padding: 18px 22px 26px; color: var(--muted); font-size: .6875rem; line-height: 1.65; }
.data-note strong { color: var(--warning); }

.map-shell { position: relative; min-width: 0; height: 100%; overflow: hidden; background: var(--map-bg); }
.map { width: 100%; height: 100%; }
.map-setup { position: absolute; inset: 0; z-index: 8; display: grid; place-content: center; justify-items: center; padding: 34px; background: var(--map-bg); text-align: center; }
.map-setup[hidden] { display: none; }
.map-setup h2 { max-width: 18ch; margin: 3px 0 10px; font-size: clamp(1.45rem, 2vw, 2rem); font-weight: 600; }
.map-setup > p:not(.setup-kicker) { max-width: 42ch; margin: 0; color: var(--muted); font-size: .8125rem; line-height: 1.75; }
.map-setup code { padding: 2px 5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.setup-rings { position: relative; display: grid; place-items: center; width: 170px; height: 170px; margin-bottom: 22px; }
.setup-rings i { position: absolute; border: 1px solid color-mix(in srgb, var(--route) 48%, transparent); border-radius: 50%; }
.setup-rings i:nth-child(1) { width: 170px; height: 170px; }
.setup-rings i:nth-child(2) { width: 118px; height: 118px; }
.setup-rings i:nth-child(3) { width: 66px; height: 66px; background: var(--route-soft); }
.setup-rings b { z-index: 1; color: var(--route-strong); font-family: var(--display); font-size: 1.6rem; }
.map-status, .map-legend, .map-tools {
  position: absolute;
  z-index: 10;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: .6875rem;
}
.map-status { top: 14px; left: 14px; max-width: calc(100% - 130px); padding: 9px 11px; }
.map-tools { top: 14px; right: 14px; }
.map-tools button { min-height: 38px; padding: 7px 11px; border: 0; background: transparent; color: var(--route-strong); font-size: .75rem; font-weight: 600; }
.map-tools button:hover { background: var(--route-soft); }
.map-tools button:disabled { color: var(--muted); cursor: not-allowed; }
.map-legend { bottom: 14px; left: 14px; display: flex; align-items: center; gap: 7px; padding: 8px 10px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50% 50% 50% 2px; background: var(--route); transform: rotate(-45deg); }

.map-marker { position: relative; display: grid; place-items: center; width: 46px; height: 50px; padding: 0; border: 0; background: transparent; }
.map-marker-shape { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid #fff; border-radius: 50% 50% 50% 7px; background: var(--route); color: var(--route-ink); font-family: var(--display); font-size: .8125rem; font-weight: 700; transform: rotate(-45deg); transition: transform .14s ease, background-color .14s ease; }
.map-marker-shape span { transform: rotate(45deg); }
.map-marker:hover .map-marker-shape, .map-marker:focus-visible .map-marker-shape, .map-marker.is-hovered .map-marker-shape { transform: rotate(-45deg) scale(1.12); }
.map-marker.is-selected .map-marker-shape { background: var(--coral); color: var(--coral-ink); transform: rotate(-45deg) scale(1.14); }
.user-marker { width: 18px; height: 18px; border: 4px solid #fff; border-radius: 50%; background: var(--location); box-shadow: 0 0 0 2px var(--location-ring); }

.info-dialog { position: relative; width: min(560px, calc(100% - 30px)); max-height: calc(100svh - 30px); padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); overflow: auto; }
.info-dialog::backdrop { background: #0b1722b8; }
.info-dialog h2 { margin: 0 50px 18px 0; font-size: 1.5rem; font-weight: 600; }
.info-dialog > p:not(.dialog-kicker), .info-dialog form + p { color: var(--muted); line-height: 1.7; }
.dialog-close { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.5rem; }
.dialog-close:hover { background: var(--route-soft); }
.detail-summary { margin: 0 0 18px; color: var(--ink) !important; font-size: 1rem; }
.detail-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 18px 0; border: 1px solid var(--line); background: var(--line); }
.detail-facts p { margin: 0; padding: 11px; background: var(--panel); color: var(--muted); font-size: .8125rem; }
.detail-facts strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: .6875rem; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.detail-chips span { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .6875rem; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.detail-actions a, .detail-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 9px 12px; border: 1px solid var(--route); border-radius: var(--radius); background: var(--route); color: var(--route-ink); font-weight: 600; text-decoration: none; }
.detail-actions .secondary { background: transparent; color: var(--route-strong); }
.warning { color: var(--warning) !important; }
.feedback-form { display: grid; gap: 16px; }
.form-note { margin: -3px 0 0; font-size: .6875rem; }
.saved-list { display: grid; border-top: 1px solid var(--line); }
.saved-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.saved-open { padding: 4px 0; border: 0; background: transparent; color: inherit; text-align: left; }
.saved-open strong { display: block; margin-bottom: 3px; }
.saved-open span { color: var(--muted); font-size: .75rem; }
.saved-remove { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--muted); font-size: .75rem; }
.saved-empty { padding: 34px 0; color: var(--muted); text-align: center; line-height: 1.65; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 100; max-width: calc(100% - 30px); padding: 10px 15px; border: 1px solid var(--line); border-radius: 999px; background: var(--ink); color: var(--panel); font-size: .75rem; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1040px) {
  .topbar { grid-template-columns: minmax(240px, 1fr) auto; }
  .topbar-promise { display: none; }
  .app-shell { grid-template-columns: 380px minmax(0, 1fr); }
}

@media (max-width: 820px) {
  body { height: auto; min-height: 100svh; overflow: auto; }
  .topbar { position: relative; z-index: 20; grid-template-columns: minmax(0, 1fr) auto; height: 70px; padding: 8px 13px; }
  .brand { gap: 8px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand p { font-size: .5625rem; }
  h1 { font-size: 1.125rem; }
  .topbar-actions { gap: 1px; }
  .text-button { padding: 6px; }
  #share-button { display: none; }
  .icon-button { width: 38px; min-height: 38px; }
  .view-switch { position: sticky; top: 0; z-index: 18; display: grid; grid-template-columns: 1fr 1fr; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .view-switch button { min-height: 42px; border: 1px solid var(--control-line); background: transparent; color: var(--muted); }
  .view-switch button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
  .view-switch button:last-child { margin-left: -1px; border-radius: 0 var(--radius) var(--radius) 0; }
  .view-switch button[aria-pressed="true"] { position: relative; border-color: var(--route); background: var(--route-soft); color: var(--route-strong); font-weight: 600; }
  .app-shell { display: block; height: auto; min-height: calc(100svh - 128px); }
  .sidebar { height: auto; min-height: calc(100svh - 128px); overflow: visible; border-right: 0; }
  .map-shell { height: calc(100svh - 128px); min-height: 430px; }
  .app-shell[data-mobile-view="list"] .map-shell { display: none; }
  .app-shell[data-mobile-view="map"] .sidebar { display: none; }
  .map-legend { display: none; }
  .map-status { top: 12px; left: 12px; }
  .map-tools { top: 12px; right: 12px; }
}

@media (max-width: 480px) {
  .topbar { padding-left: 10px; padding-right: 8px; }
  .saved-button { font-size: 0; }
  .saved-button::before { content: "清单"; font-size: .75rem; }
  .saved-button span { font-size: .625rem; }
  .filter-panel { padding: 17px 16px 15px; }
  .field-grid { grid-template-columns: 1fr; }
  .distance-field { grid-column: auto; }
  .quick-filters { flex-wrap: wrap; }
  .quick-filters legend { width: 100%; }
  .results-heading { padding-left: 16px; padding-right: 16px; }
  .place-card { padding-left: 16px; padding-right: 12px; }
  .data-note { padding-left: 16px; padding-right: 16px; }
  .detail-facts, .detail-actions { grid-template-columns: 1fr; }
  .info-dialog { padding: 24px 19px; }
  .map-setup { padding: 24px; }
  .setup-rings { width: 130px; height: 130px; }
  .setup-rings i:nth-child(1) { width: 130px; height: 130px; }
  .setup-rings i:nth-child(2) { width: 90px; height: 90px; }
  .setup-rings i:nth-child(3) { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
