:root {
  color-scheme: light;
  --paper: #f6f0e7;
  --paper-strong: #fffaf1;
  --ink: #24211d;
  --muted: #716b61;
  --line: #d9cdbc;
  --line-strong: #bcae99;
  --rust: #b85f3d;
  --teal: #247f78;
  --olive: #6f7f42;
  --blue: #426f9f;
  --amber: #b98a2f;
  --violet-muted: #705c83;
  --danger: #9f433c;
  --shadow: 0 18px 48px rgba(54, 43, 28, 0.16);
  --radius: 8px;
  --sidebar-width: minmax(360px, 30vw);
  font-family:
    Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 76px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.92);
  backdrop-filter: blur(16px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.brand h1 {
  margin: 0;
  font-size: clamp(18px, 2.1vw, 24px);
  line-height: 1.05;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.route-switcher,
.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.route-switcher {
  min-width: min(300px, 34vw);
}

.search-box {
  min-width: min(340px, 44vw);
}

.route-switcher span,
.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.route-switcher select {
  width: 100%;
  min-width: 150px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-width: 120px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.tool-button,
.text-button,
.close-button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--ink);
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.tool-button {
  height: 42px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
}

.tool-button:hover,
.text-button:hover,
.close-button:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

.tool-button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-strong);
}

.workspace {
  height: calc(100vh - 76px);
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper-strong);
}

.route-brief,
.day-summary,
.filters,
.poi-panel {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.route-brief h2,
.day-summary h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
}

.metric-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf6ed;
}

.metric strong {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.day-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.day-tab {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: var(--paper-strong);
  color: var(--ink);
  font-weight: 800;
}

.day-tab[aria-selected="true"] {
  color: var(--paper-strong);
  background: var(--ink);
}

.day-summary {
  background: #f9f1e5;
}

.day-summary p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.summary-tags,
.source-list,
.warning-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-tags {
  margin-top: 14px;
}

.tag,
.category-filter,
.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag {
  padding: 4px 9px;
  border: 1px solid rgba(36, 33, 29, 0.18);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.tag.is-warning {
  color: var(--danger);
  border-color: rgba(159, 67, 60, 0.26);
  background: rgba(159, 67, 60, 0.08);
}

.section-head {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 15px;
}

.text-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-filter {
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  background: #fffaf1;
  color: var(--ink);
}

.category-filter::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--category-color);
}

.category-filter[aria-pressed="true"] {
  border-color: var(--ink);
  background: #efe4d4;
}

.count-badge {
  min-width: 30px;
  justify-content: center;
  padding: 0 9px;
  background: var(--ink);
  color: var(--paper-strong);
}

.poi-list {
  display: grid;
  gap: 10px;
}

.poi-card {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
  color: inherit;
  text-align: left;
}

.poi-card:hover,
.poi-card.is-active {
  border-color: var(--ink);
  background: #f3eadc;
}

.poi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.poi-card h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.poi-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.day-chip {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--paper-strong);
  background: var(--day-color);
  font-size: 11px;
  font-weight: 900;
}

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

.map {
  position: absolute;
  inset: 0;
  background: #ded5c8;
}

.map-status,
.legend,
.detail-panel {
  position: absolute;
  z-index: 10;
  border: 1px solid rgba(36, 33, 29, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 250, 241, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-status {
  top: 14px;
  left: 14px;
  max-width: min(520px, calc(100% - 28px));
  padding: 9px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend {
  right: 14px;
  bottom: 18px;
  width: min(420px, calc(100% - 28px));
  padding: 12px;
}

.legend h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

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

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend-swatch {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: var(--swatch-color);
}

.legend-swatch.is-dashed {
  height: 0;
  border-top: 3px dashed var(--swatch-color);
  background: transparent;
}

.detail-panel {
  top: 58px;
  right: 14px;
  width: min(390px, calc(100% - 28px));
  max-height: calc(100% - 160px);
  overflow-y: auto;
  transform: translateX(112%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.detail-panel.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.close-button {
  position: sticky;
  top: 10px;
  left: calc(100% - 42px);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin: 10px 10px 0 auto;
  font-size: 22px;
  line-height: 1;
  z-index: 2;
}

.detail-content {
  padding: 0 18px 18px;
}

.detail-content h2 {
  margin: 4px 0 8px;
  font-size: 22px;
  line-height: 1.15;
}

.detail-content p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.detail-meta div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
}

.detail-meta strong {
  display: block;
  font-size: 12px;
}

.detail-meta span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.source-list {
  margin-top: 12px;
}

.source-link {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf1;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.source-link:hover {
  border-color: var(--ink);
}

.placeholder {
  margin: 0;
  padding: 24px 0 8px;
}

.pin {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid #fffaf1;
  border-radius: 999px 999px 999px 4px;
  background: var(--pin-color);
  color: white;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 6px 16px rgba(36, 33, 29, 0.28);
  transform: rotate(-45deg);
}

.pin span {
  transform: rotate(45deg);
}

.pin.is-muted {
  filter: grayscale(0.25);
  opacity: 0.54;
}

.leaflet-tooltip.route-label {
  padding: 5px 8px;
  border: 1px solid rgba(36, 33, 29, 0.16);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.92);
  color: var(--ink);
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
}

.leaflet-control-attribution {
  font-size: 11px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(320px, 38vw) minmax(0, 1fr);
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .legend-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .route-switcher,
  .search-box {
    width: 100%;
  }

  .tool-button {
    flex: 1 1 92px;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 68vh auto;
  }

  .sidebar {
    grid-row: 2;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-area {
    grid-row: 1;
  }

  .day-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detail-panel {
    top: auto;
    right: 10px;
    bottom: 88px;
    width: calc(100% - 20px);
    max-height: min(54vh, 520px);
  }

  .legend {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 12px;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .route-brief,
  .day-summary,
  .filters,
  .poi-panel {
    padding: 14px;
  }

  .route-brief h2,
  .day-summary h2 {
    font-size: 19px;
  }

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

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