@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@400;600;700&display=swap');

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

:root {
  --cream: #fff8f0;
  --peach: #ffe8d6;
  --coral: #ff8a5b;
  --coral-dark: #ea6a3d;
  --teal: #4ecdc4;
  --teal-dark: #2ba89f;
  --sunny: #ffd56b;
  --ink: #3d2f2a;
  --muted: #8a7870;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255, 213, 107, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(78, 205, 196, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(255, 138, 91, 0.08) 0%, transparent 50%);
}

.container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, #ff8a5b 0%, #ffd56b 60%, #4ecdc4 100%);
  color: white;
  padding: 56px 0 72px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.site-header::before,
.site-header::after {
  content: "🐾";
  position: absolute;
  font-size: 5rem;
  opacity: 0.18;
  pointer-events: none;
}
.site-header::before { top: 20px; left: 6%; transform: rotate(-18deg); }
.site-header::after  { bottom: 10px; right: 6%; transform: rotate(22deg); }

.site-header h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.2rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
  text-shadow: 0 3px 0 rgba(0,0,0,0.08);
}

.site-header h1 .paw { display: inline-block; animation: wiggle 2.5s ease-in-out infinite; }

@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(12deg); }
}

.tagline {
  font-size: 1.2rem;
  font-weight: 600;
  opacity: 0.98;
}

/* ---------- Search bar ---------- */
.search-bar {
  background: white;
  padding: 18px 0;
  box-shadow: 0 4px 20px rgba(61, 47, 42, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: -28px;
  border-radius: 28px 28px 0 0;
}

.search-bar .container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.search-bar input,
.search-bar select {
  height: 46px;
  padding: 0 20px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--cream);
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#search {
  flex: 1 1 240px;
  min-width: 200px;
}

.search-bar select {
  flex: 0 0 auto;
  min-width: 150px;
  padding-right: 38px;          /* room for the chevron */
  font-weight: 600;
  cursor: pointer;
  /* Strip native chrome so all browsers render the same pill */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  /* Custom chevron — coral, sits on the right */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5l5 5 5-5' stroke='%23ea6a3d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 8px;
}

/* Make sure the cream background doesn't override the chevron image */
.search-bar select { background-color: var(--cream); }

.search-bar input:hover,
.search-bar select:hover {
  border-color: var(--coral);
}

.search-bar input:focus,
.search-bar select:focus {
  outline: none;
  border-color: var(--coral);
  background-color: white;
  box-shadow: 0 0 0 4px rgba(255, 138, 91, 0.18);
}

/* Style the option list (works in most browsers, ignored in some — harmless) */
.search-bar select option {
  background: white;
  color: var(--ink);
  padding: 8px;
}

#sort { min-width: 170px; }

/* ---------- Main ---------- */
main { padding: 32px 0 60px; }

.results-count {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}
.results-count::before { content: "🦴 "; }

.listings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}

/* ---------- Card ---------- */
.card {
  background: white;
  border-radius: 22px;
  box-shadow: 0 4px 14px rgba(61, 47, 42, 0.07);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
}

.card-photo {
  height: 170px;
  background-size: cover;
  background-position: center;
  background-color: var(--peach);
  position: relative;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
}

.card.has-summary:hover { z-index: 25; }

.card-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(61, 47, 42, 0.15) 100%);
}

.card-photo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.35;
  z-index: -1;
}

.card-body { padding: 22px 26px 26px; }

.muted { color: var(--muted); font-style: italic; }

.card::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 22px;
  width: 34px;
  height: 34px;
  background: var(--sunny);
  border-radius: 50%;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover {
  transform: translateY(-4px) rotate(-0.3deg);
  box-shadow: 0 12px 28px rgba(61, 47, 42, 0.12);
  border-color: var(--peach);
}
.card:hover::before { opacity: 1; }

.card h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--coral-dark);
  position: relative;
  z-index: 1;
  line-height: 1.25;
}

.card .location {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.specialties {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag {
  background: var(--peach);
  color: var(--coral-dark);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tag.emergency { background: #ffd3d3; color: #c73939; }
.tag.exotic    { background: #e0f5d6; color: #4a8c2a; }
.tag.dental    { background: #d9efff; color: #2b7aba; }
.tag.surgery   { background: #f1e0ff; color: #7a4ab8; }

.card .details {
  border-top: 2px dashed var(--peach);
  padding-top: 14px;
  font-size: 0.93rem;
  color: var(--ink);
}

.card .details p { margin-bottom: 5px; }
.card .details a { color: var(--teal-dark); text-decoration: none; font-weight: 700; }
.card .details a:hover { text-decoration: underline; }

.rating {
  color: #e8a628;
  font-weight: 800;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 1.1rem;
  grid-column: 1 / -1;
}
.no-results::before {
  content: "🐶";
  display: block;
  font-size: 3.5rem;
  margin-bottom: 12px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: var(--peach);
  padding: 28px 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
}
.site-footer .hearts { color: var(--coral); }
.site-footer .attribution { font-size: 0.8rem; font-weight: 500; opacity: 0.7; margin-top: 4px; }

/* ---------- Auth bar + modal ---------- */
.auth-bar {
  position: absolute;
  top: 16px; right: 24px;
  display: flex; gap: 10px; align-items: center;
  font-size: 0.9rem;
  z-index: 2;
}
.auth-bar button {
  background: rgba(255,255,255,0.25);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.5);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.auth-bar button:hover { background: rgba(255,255,255,0.4); }
.auth-bar button.link { background: transparent; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(61, 47, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: white;
  border-radius: 20px;
  padding: 28px 28px 22px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: 10px;
}
.modal h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  color: var(--coral-dark);
  margin-bottom: 6px;
}
.modal input {
  padding: 12px 16px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--cream);
}
.modal input:focus { outline: none; border-color: var(--coral); background: white; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-actions button {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--coral); color: white;
}
.modal-actions button.secondary { background: var(--peach); color: var(--coral-dark); }
.modal .form-msg { min-height: 1.2em; color: #c73939; font-weight: 600; font-size: 0.9rem; }
.modal .switch-mode { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 4px; }
.modal .switch-mode button.link {
  background: none; border: none; color: var(--teal-dark); font-weight: 700; cursor: pointer;
  font-family: inherit; font-size: inherit; padding: 0;
}

.login-prompt {
  background: var(--cream);
  padding: 16px;
  border-radius: 14px;
  text-align: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-prompt button.link {
  background: none; border: none; color: var(--coral-dark); font-weight: 700;
  cursor: pointer; font-family: inherit; font-size: inherit; padding: 0;
  text-decoration: underline;
}
.posting-as { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- Ratings + reviews ---------- */
.ratings {
  font-size: 0.9rem;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.rating.google { color: #1a73e8; }
.rating.user { color: #e8a628; }
.rating.overall {
  background: linear-gradient(135deg, var(--coral), var(--sunny));
  color: white;
  padding: 2px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(255, 138, 91, 0.25);
}
.rating.overall small {
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.66rem;
  margin-left: 2px;
}
.rating small { color: var(--muted); font-weight: 600; }

.reviews-toggle {
  margin-top: 14px;
  background: var(--peach);
  color: var(--coral-dark);
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.reviews-toggle:hover { background: #ffd9b8; }

.reviews-panel {
  margin-top: 14px;
  border-top: 2px dashed var(--peach);
  padding-top: 14px;
}

.reviews-list { margin-bottom: 14px; }
.review {
  padding: 10px 0;
  border-bottom: 1px dashed var(--peach);
}
.review:last-child { border-bottom: none; }
.review-head { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; margin-bottom: 4px; flex-wrap: wrap; }
.review-head .stars { color: #e8a628; letter-spacing: 1px; }
.review p { font-size: 0.92rem; margin: 0; }

.review-form {
  background: var(--cream);
  padding: 14px;
  border-radius: 14px;
  margin-top: 10px;
}
.review-form .row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.review-form input[type=text] {
  flex: 1; min-width: 150px;
  padding: 8px 14px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.92rem;
  background: white;
}
.review-form textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 14px;
  border: 2px solid var(--peach);
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
  background: white;
}
.review-form button {
  margin-top: 8px;
  background: var(--coral);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.review-form button:hover { background: var(--coral-dark); }
.form-msg { font-size: 0.9rem; color: var(--teal-dark); margin-top: 6px; font-weight: 600; }

.star-picker {
  display: inline-flex;
  direction: rtl;
  background: white;
  border: 2px solid var(--peach);
  border-radius: 999px;
  padding: 4px 10px;
  align-items: center;
}
.star-picker input { display: none; }
.star-picker label { cursor: pointer; font-size: 1.2rem; color: #ddd; padding: 0 2px; }
.star-picker label:hover,
.star-picker label:hover ~ label,
.star-picker input:checked ~ label { color: #e8a628; }

/* ---------- Pagination ---------- */
.pagination {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 28px 0 8px;
}
.pagination .page-btn {
  min-width: 40px;
  padding: 8px 12px;
  background: white;
  color: var(--ink);
  border: 2px solid var(--peach);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pagination .page-btn:hover:not(:disabled) {
  border-color: var(--coral);
  color: var(--coral-dark);
}
.pagination .page-btn.active {
  background: var(--coral);
  border-color: var(--coral);
  color: white;
}
.pagination .page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.pagination .page-ellipsis {
  padding: 8px 4px;
  color: var(--muted);
}

/* ---------- AI summary popover ---------- */
.sparkle-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--coral-dark);
  font-size: 1rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(61, 47, 42, 0.18);
  z-index: 2;
}

.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(61, 47, 42, 0.12); }
.card.clickable:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.summary-modal,
.reviews-modal {
  max-width: 560px;
  padding: 24px 26px 22px;
  position: relative;
}

.reviews-modal { max-height: 80vh; overflow-y: auto; }
.reviews-modal .reviews-list { margin-bottom: 18px; }

.modal-header {
  display: flex !important;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.modal-header h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  color: var(--coral-dark);
  margin: 0;
  line-height: 1.25;
  flex: 1;
}
.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}
.modal-close:hover {
  color: var(--ink);
  background: var(--cream);
}

.summary-modal .summary-section + .summary-section { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--peach); }

.summary-modal .summary-label {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--coral-dark);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.summary-modal .modal-header h3 {
  color: var(--ink);
}

.summary-modal .summary-text {
  margin-bottom: 14px;
  line-height: 1.55;
}

.summary-modal .summary-list {
  margin: 0 0 14px 18px;
  color: var(--ink);
}
.summary-modal .summary-list li { margin: 5px 0; line-height: 1.4; }

.summary-modal .summary-link a {
  color: var(--coral-dark);
  font-weight: 600;
  text-decoration: none;
}
.summary-modal .summary-link a:hover { text-decoration: underline; }

/* ---------- Review footer + upvote ---------- */
.review-footer {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border: 1.5px solid var(--peach);
  border-radius: 999px;
  background: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.6;
}
.upvote-btn:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: rgba(78,205,196,0.08);
}
.upvote-btn.upvoted {
  border-color: var(--teal);
  background: rgba(78,205,196,0.13);
  color: var(--teal-dark);
}
.upvote-btn:disabled { cursor: default; opacity: 0.65; }

/* Pet avatar inline in reviews */
.review-pet-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  flex-shrink: 0;
}
.review-pet-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--peach);
  color: var(--coral-dark);
  font-family: 'Fredoka', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}
.review-pet-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

/* Pet selector in review form */
.review-form-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.pet-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.pet-select {
  padding: 4px 12px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  background: white;
  cursor: pointer;
  color: var(--ink);
}
.pet-select:focus { outline: none; border-color: var(--teal); }

/* ---------- Auth bar avatar ---------- */
.auth-avatar-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.25);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.5);
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.auth-avatar-btn:hover { background: rgba(255,255,255,0.4); }
.auth-avatar-img {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.auth-avatar-initial {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- Profile modal ---------- */
.profile-modal {
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
}

.profile-user {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-bottom: 22px;
  border-bottom: 2px dashed var(--peach);
  margin-bottom: 4px;
}

/* ---------- Avatar widget (shared by user + pets) ---------- */
.avatar-wrap,
.pet-avatar-wrap {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
}
.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}
.avatar-wrap:hover .avatar-overlay,
.pet-avatar-wrap:hover .avatar-overlay { opacity: 1; }

.avatar-placeholder {
  border-radius: 50%;
  background: var(--peach);
  color: var(--coral-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
}

.profile-info {
  flex: 1;
  min-width: 0;
}
.profile-username {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--coral-dark);
  line-height: 1.2;
}
.profile-email {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
  word-break: break-all;
}

/* ---------- Pets section ---------- */
.pets-section { margin-top: 6px; }

.pets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pets-header h4 {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.btn-add-pet {
  background: var(--teal);
  color: white;
  border: none;
  padding: 7px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-add-pet:hover { background: var(--teal-dark); }

.no-pets { font-size: 0.95rem; }

.pets-list { display: flex; flex-direction: column; gap: 2px; }

.pet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 6px;
  border-radius: 12px;
  transition: background 0.15s;
}
.pet-item:hover { background: var(--cream); }

.pet-info { flex: 1; min-width: 0; }
.pet-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.97rem;
}
.pet-meta {
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 2px;
}

.pet-card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.btn-edit-pet,
.btn-delete-pet {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.btn-edit-pet:hover    { color: var(--teal-dark); background: rgba(78,205,196,0.13); }
.btn-delete-pet:hover  { color: #c73939; background: #ffd3d3; }

/* ---------- Add pet form ---------- */
.add-pet-form {
  margin-top: 14px;
  background: var(--cream);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.add-pet-form input {
  padding: 10px 16px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.92rem;
  background: white;
  width: 100%;
}
.add-pet-form input:focus {
  outline: none;
  border-color: var(--teal);
  background: white;
}
.pet-form-row {
  display: flex;
  gap: 8px;
}
.pet-form-row input { flex: 1; }

.pet-birthday-field {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}
.pet-birthday-field > span { flex-shrink: 0; }
.pet-birthday-field small { font-weight: 500; opacity: 0.75; }
.pet-birthday-field input[type="date"] {
  flex: 1;
  /* let .add-pet-form input rules above style this — no overrides needed */
}
.pet-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.pet-form-actions button {
  padding: 9px 20px;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--teal);
  color: white;
  transition: background 0.15s;
}
.pet-form-actions button:hover { background: var(--teal-dark); }
.pet-form-actions button.secondary {
  background: var(--peach);
  color: var(--coral-dark);
}
.pet-form-actions button.secondary:hover { background: #ffd9b8; }
.add-pet-form .form-msg {
  font-size: 0.88rem;
  color: #c73939;
  font-weight: 600;
  min-height: 1em;
}

/* ---------- Full profile page ---------- */
#profile-page { min-height: 70vh; }

.profile-hero {
  background: linear-gradient(135deg,
    rgba(255,138,91,0.13) 0%,
    rgba(255,213,107,0.16) 55%,
    rgba(78,205,196,0.13) 100%);
  border-bottom: 2px dashed var(--peach);
  padding: 44px 0 36px;
}
.profile-hero-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.profile-hero-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 2rem;
  color: var(--coral-dark);
  margin: 0 0 4px;
}
.profile-hero-email {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 6px;
}
.profile-hero-stats {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0;
}

.profile-body { padding: 36px 0 64px; }

.profile-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 740px) {
  .profile-grid { grid-template-columns: 1fr; gap: 28px; }
}

.profile-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.profile-section-head h2,
h2.profile-section-head {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

/* Pet cards on profile page */
.pets-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pet-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(61,47,42,0.07);
  transition: border-color 0.15s;
}
.pet-card:hover { border-color: var(--peach); }
.pet-card-info { flex: 1; min-width: 0; }
.pet-card-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
.pet-card-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}
.pet-card-reviews {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(78,205,196,0.13);
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

/* Edit-mode card: same flex layout, but the form replaces the info column. */
.pet-card-editing {
  align-items: flex-start;
  border-color: var(--peach);
  background: var(--cream);
}
.pet-edit-form {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pet-edit-form input[type="text"],
.pet-edit-form input[type="date"] {
  padding: 8px 14px;
  border: 2px solid var(--peach);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.88rem;
  background: white;
  width: 100%;
}
.pet-edit-form input:focus {
  outline: none;
  border-color: var(--teal);
}
.pet-edit-form .form-msg {
  font-size: 0.83rem;
  color: #c73939;
  font-weight: 600;
  min-height: 1em;
}
.pet-edit-form .pet-form-actions button {
  padding: 7px 16px;
  font-size: 0.85rem;
}

/* Profile reviews */
.prv-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.prv-card {
  background: white;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 2px 10px rgba(61,47,42,0.07);
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.prv-card:hover { border-color: var(--peach); }
.prv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.prv-hospital {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--coral-dark);
}
.prv-stars { color: #e8a628; letter-spacing: 1px; }
.prv-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.prv-pet-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.prv-pet-placeholder {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--peach);
  color: var(--coral-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}
.prv-pet-name { font-weight: 700; color: var(--ink); }
.prv-comment {
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.55;
  margin: 0 0 12px;
}
.prv-footer { font-size: 0.83rem; color: var(--muted); }
.upvote-info { display: inline-flex; align-items: center; gap: 4px; }

/* ====================================================================
 * Mobile responsive layer
 * Two breakpoints:
 *   ≤ 640px — phones (portrait)
 *   ≤ 380px — extremely narrow phones, last-resort tweaks
 * The existing @media (max-width: 740px) for `.profile-grid` covers
 * the tablet stacking case and stays as-is.
 * ==================================================================== */

@media (max-width: 640px) {
  .container { padding: 0 16px; }

  /* --- Header --- */
  .site-header { padding: 48px 0 56px; }
  .site-header h1 {
    font-size: 2.2rem;
    margin-bottom: 6px;
    padding: 0 16px;
  }
  .site-header::before,
  .site-header::after { font-size: 3rem; opacity: 0.14; }
  .site-header::before { top: 14px; left: 4%; }
  .site-header::after  { bottom: 6px; right: 4%; }
  .tagline { font-size: 0.95rem; padding: 0 16px; }

  /* --- Auth bar --- */
  .auth-bar {
    top: 12px;
    right: 12px;
    gap: 6px;
    font-size: 0.78rem;
  }
  .auth-bar button {
    padding: 5px 10px;
    font-size: 0.76rem;
  }
  .auth-avatar-btn {
    padding: 3px 10px 3px 3px;
    gap: 5px;
  }
  .auth-avatar-img,
  .auth-avatar-initial { width: 22px; height: 22px; }
  /* Truncate long usernames so the bar can't push off-screen */
  .auth-avatar-btn span {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* --- Search bar --- */
  .search-bar {
    padding: 12px 0;
    margin-top: -22px;
    border-radius: 22px 22px 0 0;
  }
  .search-bar .container { gap: 8px; }
  .search-bar input,
  .search-bar select {
    height: 42px;
    padding: 0 16px;
    font-size: 0.9rem;
  }
  /* Drop the desktop min-widths on selects — they were forcing 3 selects
   * to claim 450px of horizontal space, which on a 360px screen meant
   * each select wrapped to its own line with weird empty space. */
  .search-bar select {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
    padding-right: 34px;
    background-position: right 12px center;
  }
  #search {
    flex: 1 1 100%;
    min-width: 0;
  }
  #sort { min-width: 0; }

  /* --- Main / listings --- */
  main { padding: 24px 0 40px; }
  .results-count { font-size: 0.95rem; margin-bottom: 16px; }
  /* Force a single column — `minmax(320px, 1fr)` overflows below 320px viewport */
  .listings { grid-template-columns: 1fr; gap: 16px; }

  /* --- Card --- */
  .card { border-radius: 20px; }
  .card-photo {
    height: 160px;
    border-radius: 18px 18px 0 0;
  }
  .card-body { padding: 18px 20px 20px; }
  .card h2 { font-size: 1.15rem; }
  .card .location { font-size: 0.9rem; }

  /* --- Pagination --- */
  .pagination { gap: 4px; margin: 22px 0 6px; }
  .pagination .page-btn {
    min-width: 36px;
    padding: 7px 10px;
    font-size: 0.85rem;
  }

  /* --- Modals (auth, reviews, summary) --- */
  .modal-backdrop { padding: 12px; }
  .modal { padding: 22px 20px 18px; gap: 8px; }
  .modal h3 { font-size: 1.2rem; }
  .summary-modal,
  .reviews-modal { padding: 20px 18px 18px; }
  .reviews-modal { max-height: 86vh; }

  /* Compact review row so author + stars + date fit on narrow screens */
  .review-head { gap: 6px 8px; font-size: 0.85rem; }
  .review p { font-size: 0.88rem; }

  /* Star picker scales down */
  .star-picker label { font-size: 1.1rem; padding: 0 1px; }

  /* Review form — keep posting-as and pet selector readable */
  .review-form-meta { gap: 8px; }
  .pet-select-label { font-size: 0.8rem; }

  /* --- Profile page --- */
  .profile-hero { padding: 32px 0 26px; }
  .profile-hero-inner { gap: 18px; }
  .profile-hero-name { font-size: 1.55rem; }
  .profile-hero-email { font-size: 0.85rem; }
  .profile-body { padding: 26px 0 50px; }

  /* Pet cards — slightly smaller avatar + inputs */
  .pet-card { padding: 10px 12px; gap: 12px; }
  .pet-form-actions button { padding: 7px 14px; font-size: 0.85rem; }

  /* Add-pet form: stack species/breed on the smallest screens */
  .add-pet-form input { font-size: 0.88rem; padding: 9px 14px; }

  /* --- Footer --- */
  .site-footer { padding: 22px 0; font-size: 0.88rem; }
  .site-footer .attribution { font-size: 0.72rem; }
}

@media (max-width: 380px) {
  .site-header h1 { font-size: 1.9rem; }
  /* On tiny screens, hide the username — the avatar is enough to identify the user */
  .auth-avatar-btn span { display: none; }
  .auth-avatar-btn { padding: 3px; }

  /* Two-up species/breed gets too tight; let them stack */
  .pet-form-row { flex-direction: column; gap: 8px; }
}
