:root {
  --bg: #1a0a2e;
  --bg-card: #2a1245;
  --bg-card-hover: #3a1a5e;
  --pink: #ff69b4;
  --purple: #b44dff;
  --purple-dim: #9b59b6;
  --text: #f0e6ff;
  --text-muted: #a78bba;
  --accent-gradient: linear-gradient(135deg, #ff69b4, #b44dff);
  --card-radius: 16px;
  --header-height: 120px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--pink);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--purple);
}

/* Header */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid rgba(180, 77, 255, 0.2);
}

.header-inner {
  text-align: center;
  padding: 24px 16px 12px;
}

.header-inner h1 {
  font-size: 2rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-top: 1px solid rgba(180, 77, 255, 0.1);
}

/* Grid */

main {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.add-collection {
  background: var(--bg-card);
  border: 1px solid rgba(180, 77, 255, 0.2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
}

.add-collection-form label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.add-collection-row {
  display: flex;
  gap: 10px;
}

.add-collection-row input {
  flex: 1;
  background: #1e0e35;
  border: 1px solid rgba(180, 77, 255, 0.35);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.add-collection-row input:focus {
  outline: none;
  border-color: var(--pink);
}

.add-collection-row button {
  border: 0;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: white;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
}

.add-collection-row button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.add-status {
  min-height: 1.2em;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.add-status[data-state="success"] {
  color: #66f0b4;
}

.add-status[data-state="error"] {
  color: #ff8ebf;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

/* Card */

.card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(180, 77, 255, 0.12);
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 32px rgba(180, 77, 255, 0.18);
  border-color: rgba(255, 105, 180, 0.3);
}

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #1e0e35;
  overflow: hidden;
}

.card-img-wrap.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #24103e 25%, #3a1a5e 50%, #24103e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: transform 0.3s ease;
}

.card-img-wrap.is-loading img {
  opacity: 0;
}

.card-img-wrap:not(.is-loading) img {
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

.card:hover .card-img-wrap img {
  transform: scale(1.05);
}

.card-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(26, 10, 46, 0.75);
  backdrop-filter: blur(6px);
  color: var(--pink);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 105, 180, 0.3);
}

.card-body {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-price {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pink);
  white-space: nowrap;
}

.card-metrics {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.card-market-cap {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ef8ad6;
  white-space: nowrap;
}

.card-price .sol-icon {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

.card-price.loading {
  color: var(--text-muted);
}

.card-market-cap.loading {
  color: var(--text-muted);
}

/* Shimmer animation for loading state */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.price-skeleton {
  display: inline-block;
  width: 60px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(180, 77, 255, 0.15) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Footer */

footer {
  text-align: center;
  padding: 32px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(180, 77, 255, 0.15);
}

/* Responsive */

@media (max-width: 600px) {
  .header-inner h1 {
    font-size: 1.4rem;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  main {
    padding: 12px;
  }

  .add-collection-row {
    flex-direction: column;
  }

  .add-collection-row button {
    height: 40px;
  }

  .card-body {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .card-name {
    font-size: 0.85rem;
  }

  .card-price {
    font-size: 0.8rem;
  }

  .card-metrics {
    align-items: flex-start;
  }
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 400px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}
