:root {
  --ink: #1d2522;
  --muted: #67736d;
  --panel: rgba(255, 252, 244, 0.92);
  --line: #d8d2c4;
  --green: #1f9a63;
  --green-dark: #0f6e45;
  --gold: #e9a23a;
  --coral: #e66b54;
  --sky: #3b82c4;
  --paper: #fbf7ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    linear-gradient(135deg, rgba(59, 130, 196, 0.16), transparent 28%),
    linear-gradient(315deg, rgba(230, 107, 84, 0.14), transparent 35%),
    #f4efe5;
}

/* ---- Shared site nav header ---- */
.site-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.site-nav-header .logo {
  font-size: 1rem;
  font-weight: 600;
  color: #222;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.site-nav-header .logo-img {
  height: 36px;
  width: 36px;
  vertical-align: middle;
}
.site-nav-header .links {
  display: flex;
  gap: 1.5rem;
}
.site-nav-header .links a {
  color: #555;
  text-decoration: none;
  font-size: 0.9rem;
}
.site-nav-header .links a:hover {
  color: #222;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 70px 24px 24px;
}

input,
select {
  font: inherit;
}

.home-back {
  position: fixed;
  top: 16px;
  left: 20px;
  color: #555;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255,255,255,0.85);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #e5e5e5;
  z-index: 100;
  transition: all 0.15s;
}
.home-back:hover {
  color: #222;
  background: rgba(255,255,255,1);
  border-color: #ccc;
}

.map-panel {
  min-height: calc(100vh - 48px);
  padding: 24px;
  border: 1px solid rgba(103, 115, 109, 0.18);
  border-radius: 18px;
  background: rgba(255, 252, 244, 0.78);
  box-shadow: 0 24px 70px rgba(49, 55, 51, 0.14);
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
  min-width: min(420px, 100%);
}

.stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.stats strong {
  display: block;
  color: var(--green-dark);
  font-size: 25px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

#visitedStat {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

#visitedStat:hover {
  border-color: var(--green-dark);
}

#visitedStat.active {
  border-color: var(--green-dark);
  background: rgba(15, 110, 69, 0.08);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
}

.map-stage {
  position: relative;
  min-height: 690px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f4eb;
}

.china-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 22px;
  opacity: 0.98;
}

.city-region-layer {
  position: absolute;
  inset: 22px;
  width: calc(100% - 44px);
  height: calc(100% - 44px);
  overflow: visible;
}

.city-region {
  fill: rgba(255, 255, 255, 0);
  stroke: rgba(125, 169, 135, 0.22);
  stroke-width: 1.2;
  cursor: pointer;
  transition: fill 180ms ease, filter 180ms ease, stroke 180ms ease;
  vector-effect: non-scaling-stroke;
}

.city-region:hover,
.city-region.selected {
  stroke: rgba(230, 107, 84, 0.92);
  stroke-width: 2;
}

.city-region.visited {
  fill: rgba(233, 162, 58, 0.72);
  stroke: rgba(174, 108, 23, 0.72);
  filter: drop-shadow(0 0 10px rgba(233, 162, 58, 0.62));
}

.city-region.visited.selected {
  fill: rgba(230, 107, 84, 0.74);
}

.map-tooltip {
  position: absolute;
  z-index: 8;
  display: none;
  max-width: 180px;
  padding: 8px 10px;
  border: 1px solid rgba(216, 210, 196, 0.9);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 252, 244, 0.96);
  box-shadow: 0 10px 24px rgba(49, 55, 51, 0.16);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
}

.map-tooltip strong {
  display: block;
  font-size: 15px;
}

.map-tooltip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.map-tooltip.visible {
  display: block;
}

.map-legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.9);
  color: var(--muted);
  font-size: 13px;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 12px;
  margin-right: 6px;
  border: 1px solid rgba(125, 169, 135, 0.58);
  border-radius: 3px;
  vertical-align: -1px;
}

.legend-swatch.visited {
  background: rgba(233, 162, 58, 0.72);
}

.legend-swatch.planned {
  background: rgba(216, 233, 213, 0.86);
}

.control-panel {
  display: flex;
  min-height: 690px;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.profile-panel {
  display: grid;
  gap: 10px;
}

.field-stack {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-stack input,
.field-stack select,
.inline-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffef8;
}

.field-stack input:focus,
.field-stack select:focus,
.inline-form input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(31, 154, 99, 0.18);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.archive-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.archive-actions .ghost-button,
.inline-form .ghost-button {
  padding: 0 10px;
}

.archive-message {
  min-height: 18px;
  color: var(--green-dark);
  font-size: 12px;
  line-height: 1.5;
}

.search-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffef8;
}

.search-box input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(31, 154, 99, 0.18);
}

.selected-city {
  min-height: 138px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
}

.selected-city h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.selected-city p {
  color: var(--muted);
  line-height: 1.6;
}

.selected-city time {
  color: var(--green-dark);
  font-weight: 700;
}

.hint {
  padding-top: 34px;
  text-align: center;
}

.city-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  color: white;
  background: var(--green-dark);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.ghost-button.danger {
  color: var(--coral);
  border-color: var(--coral);
}

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

.section-title h2 {
  font-size: 17px;
}

.city-list {
  display: grid;
  max-height: 404px;
  overflow: auto;
  gap: 8px;
  padding-right: 4px;
}

.city-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
  text-align: left;
  cursor: pointer;
}

.city-row strong {
  display: block;
  font-size: 15px;
}

.city-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  min-width: 54px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--sky);
  font-size: 12px;
  text-align: center;
}

.city-row.visited .status-pill {
  background: var(--gold);
  color: #2f2514;
}

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

@media (max-width: 980px) {
  .app-shell {
    padding: 14px;
  }

  .map-panel {
    min-height: calc(100vh - 28px);
    padding: 16px;
  }

  .topbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    min-width: 0;
  }

  .content-grid {
    display: grid;
  }

  .map-stage,
  .control-panel {
    min-height: auto;
  }

  .map-stage {
    height: min(74vw, 620px);
  }

  .city-list {
    max-height: 360px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  .map-panel {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

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

  .map-stage {
    height: 420px;
  }

  .china-backdrop {
    padding: 8px;
  }

  .city-region-layer {
    inset: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
  }

  .archive-actions {
    grid-template-columns: 1fr;
  }

}
