:root {
  --bg: #fff5f7;
  --bg-grad-a: #ffe3ea;
  --bg-grad-b: #ffd6e8;
  --card: #ffffff;
  --text: #2c2333;
  --muted: #6b6070;
  --accent: #ff6f91;
  --accent-strong: #ff4d78;
  --border: #f1dbe2;
  --shadow: 0 20px 45px -20px rgba(255, 111, 145, 0.45);
}

[data-theme="dark"] {
  --bg: #1a1420;
  --bg-grad-a: #241a2e;
  --bg-grad-b: #2c1b2a;
  --card: #241a2c;
  --text: #f4eef6;
  --muted: #b7a8c0;
  --accent: #ff8fab;
  --accent-strong: #ff6f91;
  --border: #3a2a3c;
  --shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, var(--bg-grad-a), var(--bg) 60%),
    radial-gradient(circle at bottom right, var(--bg-grad-b), transparent 60%);
  transition: background 0.3s ease, color 0.3s ease;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 20px;
}

.logo {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.logo span {
  color: var(--accent-strong);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.stage {
  display: flex;
  justify-content: center;
}

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.media {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(120deg, var(--bg-grad-a), var(--bg-grad-b));
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s ease, filter 0.15s ease;
}
.media img:hover {
  filter: brightness(0.94);
}
.media img:active {
  filter: brightness(0.88);
}
.media.loading img {
  opacity: 0.25;
  transform: scale(0.98);
}
.media.loading::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.6);
  border-top-color: var(--accent-strong);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* share / download / favorite — a little row of round buttons over the top
   right of the photo, all sharing one look */
.media-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.media-icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #6b6070;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, color 0.15s ease;
}
.media-icon-btn:hover {
  transform: scale(1.08);
  color: var(--accent-strong);
}
.like-btn.active {
  color: var(--accent-strong);
}
.like-btn.active svg {
  animation: pop 0.25s ease;
}
@keyframes pop {
  0% {
    transform: scale(0.8);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

.tagline {
  color: var(--muted);
  margin: 16px 0 4px;
  font-size: 0.95rem;
}

.breed-info {
  margin: 6px 0;
  font-size: 0.9rem;
}
.breed-info span {
  color: var(--muted);
}
.breed-info p {
  color: var(--muted);
  margin: 4px 0;
  font-size: 0.85rem;
}
.breed-info a {
  color: var(--accent-strong);
  font-size: 0.85rem;
  text-decoration: none;
}

.fact-label {
  margin: 12px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.fact {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin: 2px 0 10px;
}

.controls-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.btn:hover {
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn kbd {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ---------- "cat" buttons: two little ears poking up ---------- */
.cat-btn {
  position: relative;
  overflow: visible;
}
.cat-btn::before,
.cat-btn::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 10px solid var(--accent-strong);
  pointer-events: none;
  transition: transform 0.12s ease;
}
.cat-btn::before {
  left: 14px;
  transform: rotate(-16deg);
}
.cat-btn::after {
  right: 14px;
  transform: rotate(16deg);
}
.cat-btn.primary::before,
.cat-btn.primary::after {
  border-bottom-color: var(--accent-strong);
  filter: brightness(1.15);
}
.cat-btn:hover::before {
  transform: rotate(-22deg) translateY(-1px);
}
.cat-btn:hover::after {
  transform: rotate(22deg) translateY(-1px);
}
.cat-btn:disabled::before,
.cat-btn:disabled::after {
  opacity: 0.5;
}
/* small circular icon buttons get smaller, closer-set ears */
.icon-btn.cat-btn::before,
.icon-btn.cat-btn::after {
  border-left-width: 5px;
  border-right-width: 5px;
  border-bottom-width: 7px;
  top: -5px;
}
.icon-btn.cat-btn::before {
  left: 4px;
}
.icon-btn.cat-btn::after {
  right: 4px;
}
.btn.primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}
.btn.busy {
  opacity: 0.7;
  pointer-events: none;
}

/* purr loop toggle — deliberately bigger than the other buttons so it reads
   as its own "mode" switch rather than just another control */
.purr-btn {
  font-size: 1.05rem;
  padding: 14px 30px;
  background: var(--card);
}
.purr-btn[aria-pressed="true"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  animation: purr-pulse 1.6s ease-in-out infinite;
}
.purr-btn[aria-pressed="true"] kbd {
  opacity: 0.85;
}
@keyframes purr-pulse {
  0%,
  100% {
    box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 8px 24px -4px var(--accent-strong);
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--muted);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#breedFilter {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.85rem;
}

.stats {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal[hidden] {
  /* author styles override the UA default for [hidden]; restore it explicitly
     so toggling the hidden attribute actually shows/hides the modal */
  display: none;
}
.modal-content {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fav-cell {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1/1;
}
.fav-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fav-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

.shortcuts-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
}
.shortcuts-list kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.8rem;
  margin-right: 4px;
}

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

@media (max-width: 420px) {
  .card {
    border-radius: 18px;
    padding: 14px;
  }
}
