:root {
  /* Palette */
  --bg-color: #0f1115;
  --bg-gradient-start: #1a1d26;
  --bg-gradient-end: #0a0b0e;
  
  --primary: #6366f1; /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.4);
  --secondary: #ec4899; /* Pink */
  --accent: #22d3ee; /* Cyan */
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  
  --surface-1: rgba(30, 41, 59, 0.7);
  --surface-2: rgba(51, 65, 85, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.05);
  
  /* Layout */
  --container-width: 1200px;
  --header-height: 80px;
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  background: radial-gradient(circle at top, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --- Animated Backgrounds --- */
.glow-bg {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}
.top-left {
  top: -200px;
  left: -200px;
  background: var(--primary);
  animation: pulse-glow 10s ease-in-out infinite alternate;
}
.bottom-right {
  bottom: -200px;
  right: -200px;
  background: var(--secondary);
  animation: pulse-glow 10s ease-in-out infinite alternate-reverse;
}

@keyframes pulse-glow {
  0% { transform: scale(1); opacity: 0.1; }
  100% { transform: scale(1.2); opacity: 0.2; }
}

/* --- Layout --- */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 1rem;
}

/* --- Header --- */
.glass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-container {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: white;
}

.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s;
}
.nav-link:hover {
  color: var(--primary);
}

/* --- Controls --- */
.controls-area {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-wrapper {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  background: var(--surface-1);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
  background: var(--surface-2);
}

.btn-icon {
  background: var(--surface-1);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: var(--radius-md);
  width: 54px; /* Match height of input approx */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.counter-badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* --- Grid --- */
.pin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  border-color: var(--glass-highlight);
  z-index: 1;
}

.card > img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #2a2a2a;
  transition: transform 0.5s;
}

.card:hover > img {
  transform: scale(1.1);
}

.card-info {
  padding: 1rem;
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--glass-border);
  position: relative;
  z-index: 2;
}

.card-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #1e293b;
  width: 90%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-image-wrapper {
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
  max-height: 50vh;
  overflow: hidden;
}

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-content {
  padding: 1.5rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-description {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  flex: 1;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: white;
}

.btn-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  box-shadow: 0 4px 15px rgba(220, 39, 67, 0.4);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.5);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.modal-close:hover {
  background: rgba(0,0,0,0.8);
  transform: scale(1.1);
}

/* --- Footer --- */
.main-footer {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
}

/* Responsiveness */
@media (max-width: 600px) {
  .pin-grid {
    grid-template-columns: repeat(2, 1fr); /* Force 2 cols on mobile for Pinterest look */
    gap: 0.75rem;
  }
  .search-wrapper {
    max-width: 100%;
  }
  .controls-area {
    flex-wrap: wrap;
  }
}

/* --- Loading / Error --- */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 3rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-msg {
  text-align: center;
  padding: 2rem;
  background: rgba(239, 68, 68, 0.1); /* Red with opacity */
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  color: #fca5a5;
  margin: 2rem auto;
  max-width: 400px;
}

/* --- Upload Widget --- */
.upload-area {
  position: relative;
  width: 100%;
  min-height: 160px;
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.02);
  transition: all 0.2s ease;
  overflow: hidden;
}

.upload-area:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--primary);
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  min-height: 160px;
  cursor: pointer;
  color: var(--text-muted);
}

.preview-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}

.preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.preview-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(239,68,68,0.9);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.preview-remove:hover {
  transform: scale(1.1);
}
