* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
#sidebar {
  width: 380px;
  min-width: 380px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  padding: 20px;
  background: #fafafa;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

#search-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#location-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px; /* prevent iOS zoom */
  outline: none;
  transition: border-color 0.2s;
}

#location-input:focus {
  border-color: #4285f4;
}

#radius-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#radius-group label {
  font-size: 13px;
  color: #555;
}

#radius-select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  flex: 1;
}

#search-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: #4285f4;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

#search-btn:hover:not(:disabled) {
  background: #3367d6;
}

#search-btn:disabled {
  background: #b0c4de;
  cursor: not-allowed;
}

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

#results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Brand groups ---- */
.brand-group {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.brand-group.collapsed .place-item {
  display: none;
}

.brand-header {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  background: #f5f5f5;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.brand-header:hover {
  background: #eee;
}

.brand-count {
  font-size: 12px;
  font-weight: 400;
  color: #888;
  background: #e8e8e8;
  border-radius: 10px;
  padding: 2px 8px;
}

.place-item {
  padding: 8px 14px;
  border-top: 1px solid #f0f0f0;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.place-item:hover {
  background: #f0f7ff;
}

.place-name {
  font-weight: 500;
}

.place-address {
  color: #777;
  font-size: 12px;
  margin-top: 2px;
}

/* ---- Map ---- */
#map {
  flex: 1;
  height: 100vh;
  height: 100dvh;
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
}

/* ---- View toggle button (mobile only) ---- */
#view-toggle {
  display: none;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  body {
    flex-direction: column;
    position: relative;
  }

  #sidebar {
    width: 100%;
    min-width: unset;
    height: 100vh;
    height: 100dvh;
    border-left: none;
    padding: 16px;
    padding-bottom: 70px; /* space for toggle button */
    gap: 10px;
  }

  h1 {
    font-size: 16px;
  }

  #map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: none;
  }

  /* When map is shown */
  body.show-map #sidebar {
    display: none;
  }
  body.show-map #map {
    display: block;
    position: relative;
  }

  #view-toggle {
    display: block;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 12px 28px;
    border: none;
    border-radius: 24px;
    background: #1a1a1a;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
  }

  #view-toggle:active {
    transform: translateX(-50%) scale(0.95);
  }

  /* Compact controls on mobile */
  #radius-group {
    flex-wrap: wrap;
  }

  #search-btn {
    width: 100%;
    padding: 12px;
  }
}
