:root {
  --paper: #f8ead6;
  --paper-deep: #efd2aa;
  --panel: rgba(255, 248, 236, 0.92);
  --ink: #4a3326;
  --muted: #876a54;
  --line: #d8b98d;
  --accent: #b86f37;
  --accent-strong: #8f4c22;
  --green: #4f8a68;
  --road-point: #496f89;
  --shadow: 0 18px 50px rgba(90, 56, 28, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 249, 239, 0.9), rgba(240, 215, 182, 0.84)),
    var(--paper);
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(520px, 1fr) minmax(240px, 300px);
  gap: 18px;
  height: 100vh;
  padding: 18px;
  overflow: hidden;
}

.control-panel,
.data-panel,
.map-panel {
  border: 1px solid rgba(168, 122, 72, 0.28);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel,
.data-panel {
  min-height: 0;
  border-radius: 8px;
  padding: 20px;
  overflow: auto;
}

.map-panel {
  display: flex;
  min-height: 0;
  min-width: 0;
  max-height: calc(100vh - 36px);
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

.route-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.route-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #fffaf2;
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 111, 55, 0.16);
}

fieldset {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.radio-pill {
  display: flex !important;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffaf2;
  color: var(--ink) !important;
  cursor: pointer;
}

.radio-pill input {
  margin-right: 7px;
  accent-color: var(--accent);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  color: #fffaf2;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.message {
  min-height: 24px;
  margin: 16px 0 0;
  color: #a43f2e;
  font-size: 14px;
  line-height: 1.55;
}

.result-box {
  margin-top: 18px;
  border-top: 1px solid rgba(168, 122, 72, 0.22);
  padding-top: 18px;
}

.result-box p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.route-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 22px;
}

.route-list li {
  padding-left: 2px;
  line-height: 1.45;
}

.map-toolbar {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(168, 122, 72, 0.22);
  padding: 0 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.map-toolbar button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--accent-strong);
  background: #fffaf2;
}

.map-frame {
  position: relative;
  width: 100%;
  height: calc(100vh - 88px);
  max-height: calc(100vh - 88px);
  aspect-ratio: 2000 / 1462;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(168, 122, 72, 0.32);
  background: #ead2ad;
}

.leaflet-map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  font: inherit;
  background: #ead2ad;
}

.coord-axis {
  position: absolute;
  z-index: 650;
  pointer-events: none;
  color: rgba(74, 51, 38, 0.82);
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 250, 242, 0.9);
}

.coord-axis-top,
.coord-axis-bottom {
  left: 0;
  right: 0;
  height: 22px;
}

.coord-axis-top {
  top: 0;
  border-bottom: 1px solid rgba(74, 51, 38, 0.18);
  background: linear-gradient(rgba(255, 250, 242, 0.72), rgba(255, 250, 242, 0.18));
}

.coord-axis-bottom {
  bottom: 0;
  border-top: 1px solid rgba(74, 51, 38, 0.18);
  background: linear-gradient(rgba(255, 250, 242, 0.18), rgba(255, 250, 242, 0.76));
}

.coord-axis-left,
.coord-axis-right {
  top: 0;
  bottom: 0;
  width: 54px;
}

.coord-axis-left {
  left: 0;
  border-right: 1px solid rgba(74, 51, 38, 0.18);
}

.coord-axis-right {
  right: 0;
  border-left: 1px solid rgba(74, 51, 38, 0.18);
}

.coord-tick {
  position: absolute;
  white-space: nowrap;
}

.coord-axis-top .coord-tick,
.coord-axis-bottom .coord-tick {
  top: 4px;
  transform: translateX(-50%);
}

.coord-axis-left .coord-tick,
.coord-axis-right .coord-tick {
  left: 5px;
  transform: translateY(-50%);
}

.building-marker {
  display: grid;
  min-width: 66px;
  justify-items: center;
  gap: 3px;
  color: var(--ink);
}

.building-marker span {
  max-width: 110px;
  padding: 2px 4px;
  color: var(--ink);
  background: rgba(255, 250, 242, 0.78);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.building-marker.active .pin {
  background: var(--accent);
}

.building-marker.active span {
  color: var(--accent-strong);
  background: rgba(255, 250, 242, 0.88);
}

.building-marker.start-selected .pin {
  background: #3f8a65;
}

.building-marker.end-selected .pin {
  background: #a85f35;
}

.building-marker.start-selected span,
.building-marker.end-selected span {
  color: var(--ink);
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 0 0 2px rgba(255, 250, 242, 0.8);
}

.marker {
  position: absolute;
  display: grid;
  min-width: 66px;
  transform: translate(-50%, -100%);
  justify-items: center;
  gap: 3px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}

.marker:hover {
  background: transparent;
}

.pin {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid #fffaf2;
  border-radius: 50% 50% 50% 0;
  background: var(--green);
  box-shadow: 0 3px 10px rgba(67, 46, 27, 0.22);
  transform: rotate(-45deg);
}

.pin::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fffaf2;
  content: "";
}

.marker span {
  max-width: 110px;
  border: 0;
  border-radius: 0;
  padding: 2px 4px;
  color: var(--ink);
  background: rgba(255, 250, 242, 0.78);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.marker.active .pin {
  background: var(--accent);
}

.marker.active span {
  color: var(--accent-strong);
  background: rgba(255, 250, 242, 0.88);
}

.data-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 36px);
  overflow: hidden;
}

.edge-list {
  display: grid;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.edge-item {
  width: 100%;
  min-height: auto;
  border: 1px solid rgba(168, 122, 72, 0.24);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--muted);
  background: rgba(255, 250, 242, 0.72);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
}

.edge-item:hover,
.edge-item.active {
  color: var(--ink);
  background: rgba(255, 246, 231, 0.98);
}

.edge-item.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 300px 1fr;
  }

  .data-panel {
    grid-column: 1 / -1;
    max-height: 260px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .map-panel {
    order: -1;
  }

  .map-frame {
    max-height: none;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 22px;
  }

  fieldset {
    grid-template-columns: 1fr;
  }

  .marker {
    min-width: 58px;
  }

  .marker span {
    max-width: 82px;
    font-size: 11px;
  }
}
