* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

body {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
}

#sidebar {
  padding: 16px;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  background: #fafafa;
}

#sidebar h1 {
  margin: 0 0 16px;
  font-size: 18px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: #333;
}

.input-row {
  display: flex;
  gap: 4px;
}

.ac-slot {
  flex: 1;
  min-width: 0;
}

.ac-slot gmp-place-autocomplete {
  width: 100%;
}

.geo-btn {
  width: 36px;
  border: 1px solid #ccc;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

.geo-btn:hover {
  background: #eee;
}

.selected-label {
  margin-top: 4px;
  font-size: 12px;
  color: #137333;
  min-height: 16px;
}

#category, #midpoint-mode, #units, #radius {
  width: 100%;
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.map-control {
  background: white;
  margin: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  border: none;
  cursor: pointer;
}

#radius {
  padding: 0;
}

#find-btn {
  width: 100%;
  padding: 10px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}

#find-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#find-btn:not(:disabled):hover {
  background: #1557b0;
}

#status {
  margin-top: 12px;
  color: #666;
  font-size: 13px;
  min-height: 18px;
}

#status.error {
  color: #c00;
}

#results {
  margin-top: 12px;
  padding-left: 20px;
}

#results li {
  cursor: pointer;
  padding: 8px 4px;
  border-bottom: 1px solid #eee;
  list-style: decimal;
}

#results li:hover {
  background: #eef4ff;
}

#results li.selected {
  background: #d4e3ff;
  font-weight: 500;
}

.result-name {
  display: block;
}

.result-dist {
  display: block;
  font-size: 12px;
  color: #666;
}

#map {
  width: 100%;
  height: 100%;
}

.legend {
  background: white;
  padding: 8px 12px;
  margin: 10px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  font-size: 12px;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.legend-title {
  font-weight: 600;
}

.legend-actions {
  display: flex;
  gap: 4px;
}

.legend-btn {
  background: #f1f3f4;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #1a73e8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-btn:hover:not(:disabled) {
  background: #e8eaed;
}

.legend-btn-primary {
  background: #1a73e8;
  border-color: #1a73e8;
  color: white;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.legend-btn-primary:hover:not(:disabled) {
  background: #1557b0;
  border-color: #1557b0;
}

.legend-btn-icon {
  font-size: 12px;
  line-height: 1;
}

.legend-btn:disabled {
  background: #137333;
  border-color: #137333;
  color: white;
  cursor: default;
  box-shadow: none;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.share-menu {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.share-menu-item {
  display: block;
  padding: 8px 10px;
  border-radius: 4px;
  color: #1a73e8;
  text-decoration: none;
  font-size: 13px;
}

.share-menu-item:hover,
.share-menu-item:active {
  background: #f1f3f4;
}

.legend-swatch {
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

#mobile-results {
  display: none;
}

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
  }

  #sidebar {
    border-right: none;
    border-bottom: 1px solid #ddd;
    overflow: visible;
    max-height: none;
  }

  #map {
    width: auto;
    height: 75vh;
    min-height: 400px;
    margin: 12px;
    border-radius: 8px;
    overflow: hidden;
  }

  #mobile-results {
    display: block;
    background: #fafafa;
  }

  #mobile-results #results {
    margin: 0;
    padding: 0 16px 16px 40px;
  }

  #mobile-results #results:not(:empty) {
    padding-top: 16px;
    border-top: 1px solid #ddd;
  }
}
