:root {
  --primary: #2c5f2d;
  --primary-dark: #1e4620;
  --accent: #ff9800;
  --accent-light: #ffe8cc;
  --gray-light: #f5f5f5;
  --gray-medium: #ccc;
  --gray-dark: #333;
  --success: #4caf50;
  --success-dark: #388e3c;
  --danger: #f44336;
  --badge-community: #ffd54f;
  --badge-community-text: #f57f17;
  --badge-verified: #c8e6c9;
  --badge-verified-text: #2e7d32;
  --badge-service: #e3f2fd;
  --badge-service-text: #1976d2;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-dark);
  background: var(--gray-light);
  padding: 0 20px 100px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

main {
  max-width: 600px;
  margin: 0 auto;
}

.app-header {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 0 12px;
  text-align: center;
}

.app-header h1 {
  font-size: 28px;
  font-weight: bold;
  color: var(--primary);
  margin: 0 0 6px;
}

.app-header .subtitle {
  font-size: 15px;
  color: var(--gray-dark);
  margin: 0;
}

.search-section {
  position: sticky;
  top: 0;
  background: var(--gray-light);
  padding: 12px 0;
  z-index: 10;
}

.search-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 16px;
  border: 2px solid var(--gray-medium);
  border-radius: 8px;
  background: white;
  transition: 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 45, 0.1);
}

.filter-section {
  padding: 4px 0 12px;
}

.filter-buttons {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.filter-btn {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 2px solid var(--gray-medium);
  border-radius: 20px;
  background: white;
  color: var(--gray-dark);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}

.filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.results-meta {
  font-size: 14px;
  color: var(--gray-dark);
  padding: 4px 0 12px;
}

.results-section {
  padding-bottom: 20px;
}

.resource-card {
  background: white;
  border: 1px solid var(--gray-medium);
  border-radius: 8px;
  padding: 15px;
  margin: 12px 0;
  transition: 0.2s;
}

.resource-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.resource-card.community-added {
  border-left: 4px solid var(--accent);
}

.resource-name {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}

.badge-row {
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  margin: 0 6px 6px 0;
}

.badge-verified {
  background: var(--badge-verified);
  color: var(--badge-verified-text);
}

.badge-community {
  background: var(--badge-community);
  color: var(--badge-community-text);
}

.badge-service {
  background: var(--badge-service);
  color: var(--badge-service-text);
}

.badge-emergency {
  background: var(--danger);
  color: white;
}

.resource-meta {
  font-size: 14px;
  color: #555;
  margin: 4px 0;
}

.resource-description {
  font-size: 14px;
  margin: 8px 0;
  color: var(--gray-dark);
}

.resource-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

button, .btn {
  font-family: inherit;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: 0.2s;
}

.call-btn {
  background: var(--success);
  color: white;
  flex: 1 1 auto;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.call-btn:active {
  transform: scale(0.98);
  background: var(--success-dark);
}

.share-btn, .link-btn {
  background: white;
  border: 2px solid var(--gray-medium);
  color: var(--gray-dark);
  flex: 1 1 auto;
}

.share-btn:active, .link-btn:active {
  transform: scale(0.98);
}

.no-results {
  text-align: center;
  color: #777;
  padding: 40px 20px;
}

.add-resource-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
  z-index: 100;
}

.add-resource-btn:active {
  transform: scale(0.98);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
}

#add-resource-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 6px;
}

#add-resource-form .required {
  color: var(--danger);
}

#add-resource-form input,
#add-resource-form select,
#add-resource-form textarea {
  width: 100%;
  font-size: 16px;
  padding: 10px;
  border: 1px solid var(--gray-medium);
  border-radius: 6px;
  font-family: inherit;
}

#add-resource-form input:focus,
#add-resource-form select:focus,
#add-resource-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 45, 0.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  flex: 1;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  border: 2px solid var(--gray-medium);
  color: var(--gray-dark);
  flex: 1;
}

.confirmation {
  background: var(--badge-verified);
  color: var(--badge-verified-text);
  padding: 15px;
  border-radius: 8px;
  margin-top: 16px;
  text-align: center;
  font-weight: 600;
}

.confirmation.hidden {
  display: none;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 20px;
  right: 20px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--gray-dark);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  z-index: 200;
  transition: opacity 0.3s;
}

.toast.hidden {
  display: none;
}

/* Tablet */
@media (min-width: 600px) {
  body {
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* Desktop */
@media (min-width: 900px) {
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .app-header,
  main,
  .add-resource-btn {
    width: 100%;
    max-width: 600px;
  }
}

/* Accessibility: visible focus states everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
