.map-category-control {
  position: absolute;
  z-index: 700;
  right: 12px;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  width: 198px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 50px);
  overflow: hidden;
  border: 1px solid #d5ddcd;
  border-radius: 12px;
  background: #fffefa;
  color: var(--ink, #384331);
  box-shadow: 0 5px 22px #263b2b22;
  font: 12px/1.5 "Noto Sans TC", system-ui, sans-serif;
  overscroll-behavior: contain;
}

.map-category-toggle {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  background: #f2f5e9;
  color: inherit;
  text-align: left;
}

.map-category-heading {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
}

.map-category-tally {
  padding: 2px 6px;
  border-radius: 5px;
  background: #e2e9d6;
  color: #536448;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.map-category-chevron {
  font-size: 17px;
  line-height: 1;
  transform: rotate(0deg);
}

.map-category-control.is-collapsed .map-category-chevron {
  transform: rotate(180deg);
}

.map-category-body {
  min-height: 0;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c2ceb5 transparent;
  -webkit-overflow-scrolling: touch;
}

.map-category-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px 9px;
  border-bottom: 1px solid #e7ebdf;
}

.map-category-actions button {
  min-height: 44px;
  padding: 5px 3px;
  border-radius: 6px;
  background: transparent;
  color: #5a704b;
  font-size: 10px;
}

.map-category-actions button:hover {
  background: #edf2e4;
}

.map-category-options {
  padding: 3px 7px;
}

.map-category-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 5px 6px;
  border-radius: 7px;
  cursor: pointer;
}

.map-category-option:hover {
  background: #f1f4e9;
}

.map-category-option:has(input:focus-visible) {
  outline: 2px solid #bd7c4b;
  outline-offset: -2px;
}

.map-category-option input[type="checkbox"] {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--map-category-color);
}

.map-category-symbol {
  display: inline-flex;
  flex: 0 0 21px;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--map-category-color);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.map-category-label {
  flex: 1;
  min-width: 0;
  font-size: 11px;
}

.map-category-count {
  color: #7b866e;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.map-category-status {
  margin: 0;
  padding: 9px 12px 11px;
  border-top: 1px solid #e7ebdf;
  color: #6f7d61;
  font-size: 10px;
  line-height: 1.7;
}

.map-category-toggle:focus-visible,
.map-category-actions button:focus-visible {
  outline: 3px solid #bd7c4b;
  outline-offset: -3px;
}

@media (max-width: 760px) {
  .map-category-control {
    right: 9px;
    bottom: 25px;
    width: 180px;
    max-height: calc(100% - 44px);
    border-radius: 10px;
  }
  .map-category-body { max-height: 278px; }
  .map-category-toggle { padding: 9px 11px; }
}

@media print {
  .map-category-control { display: none !important; }
}
