/* 碰头点 — warm paper gathering aesthetic */

:root {
  --paper: #f4efe4;
  --paper-deep: #ebe3d4;
  --card: #fffcf6;
  --ink: #1c1612;
  --ink-soft: #5c534a;
  --ink-faint: #8a8076;
  --accent: #d94f2b;
  --accent-deep: #b03a1a;
  --sage: #6d7f62;
  --line: rgba(28, 22, 18, 0.12);
  --shadow: 0 12px 40px rgba(28, 22, 18, 0.12), 0 2px 8px rgba(28, 22, 18, 0.06);
  --shadow-soft: 0 4px 16px rgba(28, 22, 18, 0.08);
  --radius: 18px;
  --panel-w: 380px;
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --font-body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* —— layout —— */

.app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100%;
  position: relative;
}

.panel {
  background:
    radial-gradient(ellipse 120% 40% at 0% 0%, rgba(217, 79, 43, 0.06), transparent 55%),
    linear-gradient(180deg, var(--card) 0%, var(--paper) 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  transition: transform 0.45s var(--ease);
}

.panel.is-collapsed {
  transform: translateX(-100%);
}

/* —— header —— */

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 24px 12px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.tagline {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.btn-ghost {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.7);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(217, 79, 43, 0.35);
  background: #fff;
}

/* —— people —— */

.people-section {
  padding: 8px 24px 8px;
}

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

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.count {
  font-size: 12px;
  color: var(--ink-faint);
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  min-height: 12px;
}

.person-list:empty::after {
  content: "还没有添加地址";
  display: block;
  text-align: center;
  padding: 20px 12px;
  color: var(--ink-faint);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 252, 246, 0.4);
}

.person-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 12px 12px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  animation: rise-in 0.4s var(--ease) both;
}

.person-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.person-info {
  min-width: 0;
}

.person-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.person-addr {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-top: 2px;
  word-break: break-word;
}

.person-geo {
  font-size: 11px;
  color: var(--sage);
  margin-top: 4px;
}

.person-geo.is-pending {
  color: var(--ink-faint);
}

.person-geo.is-error {
  color: var(--accent);
}

.person-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: color 0.15s, background 0.15s;
}

.person-remove:hover {
  color: var(--accent);
  background: rgba(217, 79, 43, 0.08);
}

/* —— form —— */

.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-row input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.85);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.add-row input::placeholder {
  color: var(--ink-faint);
}

.add-row input:focus {
  border-color: rgba(217, 79, 43, 0.5);
  box-shadow: 0 0 0 3px rgba(217, 79, 43, 0.12);
  background: #fff;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed rgba(28, 22, 18, 0.2);
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-add:hover {
  color: var(--accent);
  border-color: rgba(217, 79, 43, 0.45);
  background: rgba(217, 79, 43, 0.04);
}

.btn-add-icon {
  font-size: 16px;
  line-height: 1;
}

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
}

/* —— result —— */

.result-section {
  padding: 16px 24px 8px;
}

.result-card {
  position: relative;
  padding: 18px 16px 14px;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(217, 79, 43, 0.08), transparent 50%),
    var(--card);
  border: 1px solid rgba(217, 79, 43, 0.22);
  box-shadow: var(--shadow);
  animation: rise-in 0.45s var(--ease) both;
}

.result-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: rgba(217, 79, 43, 0.1);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.result-addr {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.result-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.distance-list {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.distance-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-soft);
}

.distance-list .d-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.distance-list .d-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  flex-shrink: 0;
}

.distance-list .d-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* —— actions —— */

.actions {
  padding: 12px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-soft);
  transition: background 0.2s, transform 0.15s var(--ease);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(244, 239, 228, 0.3);
  border-top-color: var(--paper);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-secondary {
  padding: 10px;
  font-size: 12px;
  color: var(--ink-faint);
  transition: color 0.15s;
}

.btn-secondary:hover {
  color: var(--accent);
}

/* —— footer —— */

.panel-footer {
  margin-top: auto;
  padding: 20px 24px 24px;
  font-size: 10px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.panel-footer p {
  margin: 0;
}

.footer-note {
  margin-top: 4px !important;
  opacity: 0.8;
}

/* —— map —— */

.map-wrap {
  position: relative;
  min-width: 0;
  background: var(--paper-deep);
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-overlay-top {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  pointer-events: none;
}

.status-pill {
  background: rgba(28, 22, 18, 0.88);
  color: var(--paper);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  animation: rise-in 0.3s var(--ease);
}

.panel-toggle {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 28px;
  height: 56px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: none;
  place-items: center;
}

.panel-toggle span {
  display: block;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg) translate(2px, -2px);
}

.panel.is-collapsed + .map-wrap .panel-toggle span {
  transform: rotate(-135deg) translate(2px, -2px);
}

/* —— map markers —— */

.marker-person,
.marker-center {
  background: none;
  border: none;
}

.pin-person {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  display: grid;
  place-items: center;
  box-shadow:
    0 4px 14px rgba(28, 22, 18, 0.28),
    0 0 0 3px rgba(255, 252, 246, 0.9);
  border: 2px solid var(--paper);
}

.pin-center {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow:
    0 6px 20px rgba(217, 79, 43, 0.45),
    0 0 0 4px rgba(255, 252, 246, 0.95);
  border: 2px solid #fff;
  animation: pulse-pin 2s ease-in-out infinite;
}

.pin-center svg {
  width: 20px;
  height: 20px;
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  padding: 0;
}

.leaflet-popup-content {
  margin: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
}

.popup-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.popup-sub {
  font-size: 11px;
  color: var(--ink-soft);
}

/* —— toast —— */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: toast-in 0.35s var(--ease);
  max-width: min(90vw, 360px);
  text-align: center;
}

/* —— animations —— */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-pin {
  0%,
  100% {
    box-shadow:
      0 6px 20px rgba(217, 79, 43, 0.45),
      0 0 0 4px rgba(255, 252, 246, 0.95);
  }
  50% {
    box-shadow:
      0 6px 24px rgba(217, 79, 43, 0.6),
      0 0 0 8px rgba(217, 79, 43, 0.18);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* —— responsive —— */

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 48vh 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    order: 2;
  }

  .panel.is-collapsed {
    transform: translateY(0);
    display: none;
  }

  .map-wrap {
    order: 1;
  }

  .panel-toggle {
    display: grid;
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 28px;
  }

  .panel-toggle span {
    transform: rotate(135deg) translate(0, -1px);
  }

  .panel.is-collapsed + .map-wrap .panel-toggle span {
    transform: rotate(-45deg) translate(0, -1px);
  }

  .panel-header {
    padding-top: 16px;
  }
}
