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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: #eef2f8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

/* Fixed palette container size — percentage of viewport (75% width, 70% height) */
.palette-container {
  width: 75vw;
  height: 90vh;
  min-width: 340px;
  min-height: 480px;
  max-width: 1300px;
  max-height: 85vh;
  background: white;
  border-radius: 2rem;
  box-shadow: 0 25px 45px -12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s;
}

/* Header area: theme name + clickable link */
.palette-header {
  padding: 1rem 1.8rem 0.8rem 1.8rem;
  border-bottom: 2px solid #eef2f6;
  flex-shrink: 0;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.theme-info {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.theme-label {
  font-size: 1.7rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1e293b, #334155);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  letter-spacing: -0.3px;
}

/* Link style: no underline, color change on hover */
.theme-link {
  font-size: 0.85rem;
  background: #eef2ff;
  padding: 0.3rem 0.9rem;
  border-radius: 40px;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #2563eb;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-link:hover {
  background: #dbeafe;
  color: #1d4ed8;
  text-decoration: none;
  transform: translateY(-1px);
}

.theme-link:active {
  transform: scale(0.97);
}

/* Navigation button group */
.nav-buttons {
  display: flex;
  gap: 0.8rem;
}

.nav-btn {
  background: #f1f5f9;
  border: none;
  padding: 0.45rem 1.2rem;
  border-radius: 40px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.nav-btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.nav-btn:active {
  transform: translateY(1px);
}

/* Palette border scroll container (rectangular frame) */
.palette-wrapper {
  flex: 1;
  margin: 0.8rem 1.2rem 1.2rem 1.2rem;
  border: 3px solid #334155;
  border-radius: 1.2rem;
  background: #fafcff;
  overflow-y: auto;
  padding: 0.6rem;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Grid layout: max 4 items per row */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  padding: 0.6rem;
}

/* Color card */
.color-card {
  display: flex;
  flex-direction: column;
  border-radius: 1rem;
  overflow: hidden;
  background: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.color-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 20px -10px rgba(0, 0, 0, 0.15);
}

.color-swatch {
  width: 100%;
  aspect-ratio: 2 / 1;
  background-color: #ccc;
  transition: filter 0.1s;
}

.color-card:active .color-swatch {
  filter: brightness(0.92);
}

.color-value {
  text-align: center;
  padding: 0.6rem 0.3rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  background: #ffffff;
  color: #1e293b;
  border-top: 1px solid #f0f0f0;
  letter-spacing: 0.3px;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: #1e293b;
  color: white;
  padding: 0.6rem 1.4rem;
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Scrollbar styling */
.palette-wrapper::-webkit-scrollbar {
  width: 8px;
}

.palette-wrapper::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 10px;
  margin: 6px 0;
}

.palette-wrapper::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
}

.palette-wrapper::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem;
  font-size: 1rem;
  color: #475569;
}

/* Mobile adjustments */
@media (max-width: 620px) {
  .palette-container {
    width: 90vw;
    height: 75vh;
  }

  .palette-grid {
    gap: 0.7rem;
  }

  .color-value {
    font-size: 0.7rem;
    padding: 0.4rem 0.2rem;
  }

  .nav-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.75rem;
  }

  .theme-label {
    font-size: 1.3rem;
  }
}
