.map-layer-controls {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
}

.layer-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px 16px;
}

.layer-heading h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
}

.layer-heading small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.route-mode-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0;
  padding: 3px;
  border: 1px solid #e4e7db;
  border-radius: 9px;
  background: #f5f6ee;
}

.route-mode-switch button {
  min-height: 44px;
  min-width: 84px;
  padding: 8px 14px;
  border-radius: 6px;
  background: transparent;
  color: #79866c;
  font-size: 11px;
  font-weight: 500;
}

.route-mode-switch button:hover:not(:disabled) {
  background: #e8eddd;
}

.route-mode-switch button.active,
.route-mode-switch button[aria-pressed="true"] {
  background: var(--green);
  color: #fffefa;
  box-shadow: 0 2px 4px #263d3112;
}

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

.route-day-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 64px;
  padding: 6px 8px 6px 11px;
  border: 1px solid #e4e7dd;
  border-left: 4px solid var(--day-color, #c1cab5);
  border-radius: 8px;
  background: #fafbf6;
  transition: background .15s, box-shadow .15s;
}

.route-day-option.is-visible {
  background: #fffefa;
  box-shadow: 0 0 0 1px var(--day-color, #a0b18b) inset;
}

.route-day-option.is-empty {
  border-left-style: dashed;
  background: #f6f6ef;
}

.route-day-option > label {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  cursor: pointer;
}

.route-day-option.is-empty > label {
  cursor: default;
}

.route-day-option input[type="checkbox"],
.route-day-option input[type="radio"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--day-color, var(--green));
}

.route-day-label {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
  min-width: 0;
  min-height: 44px;
}

.route-day-label strong {
  font-size: 11px;
  line-height: 1.7;
  font-weight: 600;
}

.route-day-label small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.route-day-only {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 48px;
  padding: 8px 6px;
  border: 1px solid #e5e8dc;
  border-radius: 6px;
  background: #f1f4e8;
  color: #63774f;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.route-day-only:hover:not(:disabled) {
  border-color: var(--day-color, #b8c6a8);
  background: #e6edd9;
}

.route-layer-summary {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.map-layer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.map-layer-actions > button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #dce3d1;
  border-radius: 7px;
  background: #edf2e3;
  color: #597048;
  font-size: 10px;
  font-weight: 500;
}

.map-layer-actions > button:hover:not(:disabled) {
  background: #e0e9d2;
}

.map-legend {
  position: static;
  z-index: auto;
  display: block;
  margin-top: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--muted);
  font-size: 10px;
  box-shadow: none;
}

.category-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 15px;
}

.category-legend > strong {
  color: #5f7152;
  font-size: 10px;
  font-weight: 600;
  margin-right: 2px;
}

.category-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.category-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 6px;
  background: var(--category-color, #627a4f);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  font-style: normal;
}

.marker-legend-note {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #edf0e5;
  font-size: 10px;
  line-height: 1.9;
  color: #7d8872;
}

.pin,
.pin.is-selected,
.pin.is-stay {
  position: relative;
  width: 35px;
  height: 35px;
  border: 4px solid var(--day-color, #fffefa);
  background: var(--category-color, #627a4f);
  box-shadow: 0 1px 7px #20372c50, 0 0 0 1px #fffefa;
  color: #fff;
}

.pin.is-scheduled {
  border-color: var(--day-color, #fffefa);
  box-shadow: 0 0 0 1px #fffefa, 0 3px 9px #20372c55;
}

.pin.is-muted {
  opacity: .43;
}

.pin > .pin-symbol,
.pin.is-stay > .pin-symbol {
  transform: rotate(45deg);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 1px #0002;
}

.pin-selection,
.pin-day-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: 0 0;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  pointer-events: none;
}

.pin-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  transform: rotate(45deg) translate(9px, -20px);
  border: 1.5px solid #fffefa;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 9px;
  line-height: 1;
}

.pin-day-label {
  min-width: 34px;
  padding: 2px 5px;
  transform: rotate(45deg) translate(-50%, 20px);
  border: 1px solid var(--day-color, #b7c5a7);
  border-radius: 5px;
  background: #fffefaf5;
  box-shadow: 0 1px 4px #263d3120;
  color: #354a35;
  text-align: center;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
}

.map-route-popup {
  color: #637450;
  font-size: 11px;
  line-height: 1.8;
}

.map-route-popup strong {
  display: block;
  color: var(--ink);
}

@media (min-width: 1400px) {
  .route-day-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .route-day-option {
    flex-wrap: wrap;
    gap: 0 8px;
    align-content: start;
  }
  .route-day-option > label {
    flex-basis: 100%;
  }
  .route-day-only {
    width: 100%;
    margin-top: 3px;
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .map-layer-controls {
    padding: 13px;
  }
  .route-mode-switch {
    display: flex;
    width: 100%;
  }
  .route-mode-switch button {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 10px;
  }
  .route-day-list {
    grid-template-columns: 1fr;
  }
  .route-day-option {
    min-height: 60px;
  }
  .route-day-only {
    min-width: 64px;
  }
  .map-legend {
    padding: 12px;
    font-size: 10px;
  }
  .category-legend {
    gap: 8px 12px;
  }
  .category-legend > strong {
    flex-basis: 100%;
  }
  .marker-legend-note {
    font-size: 9px;
  }
}
