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

:root {
  --blue: #2d7fc1;
  --dark-blue: #1a5276;
  --light-blue: #d4e6f1;
  --teal: #1abc9c;
  --dark: #2c3e50;
  --gray: #7f8c8d;
  --light-gray: #f0f3f5;
  --border: #dcdde1;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #e8f4fd 0%, #d5f5e3 100%);
  color: var(--dark);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 24px 0 16px;
}

h1 { font-size: 1.8rem; color: var(--dark-blue); margin-bottom: 4px; }
.subtitle { color: var(--gray); font-size: 0.9rem; }
h2 { font-size: 1.1rem; color: var(--dark); margin-bottom: 8px; }
.hidden { display: none !important; }

/* Location */
.location-card {
  background: white;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--gray);
  margin-bottom: 12px;
}
.loc-icon { font-size: 1.1rem; }

/* Controls */
.controls-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.slider-row {
  margin-bottom: 12px;
}
.slider-row label {
  font-size: 0.9rem;
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}
#range-value {
  color: var(--blue);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--light-blue);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.btn-primary {
  background: var(--blue);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--dark-blue); }

/* Status */
#status { display: flex; justify-content: center; padding: 40px 0; }
.loading { text-align: center; }
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#status-text { color: var(--gray); font-size: 0.9rem; }

/* Map */
.map-section { margin-bottom: 20px; }
.leaflet-map {
  height: 350px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.badge {
  background: var(--blue);
  color: white;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin-left: 6px;
}

/* List */
.list-header {
  margin-bottom: 12px;
}
.insect-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.insect-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  cursor: pointer;
}
.insect-card:hover { transform: translateY(-2px); }
.insect-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--light-gray);
}
.insect-card .info {
  padding: 10px 12px;
}
.insect-card .name {
  font-weight: 600;
  font-size: 0.9rem;
}
.insect-card .sci-name {
  font-size: 0.78rem;
  color: var(--gray);
  font-style: italic;
  margin-bottom: 2px;
}
.insect-card .meta {
  font-size: 0.72rem;
  color: #b2bec3;
}
.insect-card .icon-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 140px; background: var(--light-gray);
  color: var(--gray); font-size: 2rem;
}

/* Error */
.error-card {
  background: #fff5f5; border: 1px solid #fed7d7;
  border-radius: var(--radius); padding: 20px;
  color: #c53030; text-align: center; margin: 20px 0;
}

/* Footer */
footer { text-align: center; padding: 40px 0 20px; color: var(--gray); font-size: 0.8rem; }
footer a { color: var(--blue); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 500px) {
  .container { padding: 12px; }
  h1 { font-size: 1.4rem; }
  .insect-list { grid-template-columns: 1fr; }
  .leaflet-map { height: 280px; }
}
