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

:root {
  --bg: #faf8fb;
  --fg: #1d1d1f;
  --muted: #86868b;
  --surface: #ffffff;
  --border: rgba(0, 0, 0, 0.04);
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-strong: rgba(0, 0, 0, 0.12);
  --accent: #d946ef;
  --accent-hover: #e879f9;
  --success: #34c759;
  --error: #ff3b30;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, #fdf4ff 0%, #faf5ff 50%, #f5f3ff 100%);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 80px 24px 120px;
}

/* Typography */
.headline {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 16px;
}

.subtitle {
  font-size: 21px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 16px;
}

.usage-counter {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 48px;
  display: none;
}

.usage-counter.show {
  display: block;
}

/* Upload Card */
.upload-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 48px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 4px 12px var(--shadow),
    0 1px 3px var(--shadow);
  margin-bottom: 24px;
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-area:hover {
  background: #f0f0f0;
}

.upload-area.dragover {
  background: #fae8ff;
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.upload-text {
  font-size: 17px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 14px;
  color: var(--muted);
}

input[type="file"] {
  display: none;
}

.upload-area.hidden {
  display: none;
}

/* Preview */
.preview-container {
  display: none;
  position: relative;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.preview-container.show {
  display: block;
}

.preview-image {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.preview-container:hover .preview-overlay {
  opacity: 1;
}

.preview-overlay-text {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}

.preview-info {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  display: none;
}

.preview-info.show {
  display: block;
}

.color-check {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.color-check.show {
  display: block;
}

.color-check.success {
  background: rgba(52, 199, 89, 0.1);
  color: #248a3d;
}

.color-check.warning {
  background: rgba(255, 149, 0, 0.1);
  color: #c93400;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 32px;
  font-size: 17px;
  font-weight: 500;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 2px 8px rgba(217, 70, 239, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.02);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 4px 16px rgba(217, 70, 239, 0.45);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid rgba(217, 70, 239, 0.2);
  box-shadow: 0 1px 3px var(--shadow);
}

.btn-secondary:hover {
  background: #fdf4ff;
}

.actions {
  margin-top: 32px;
}

/* Result Messages */
.result {
  margin-top: 24px;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  display: none;
  text-align: center;
}

.result.show {
  display: block;
}

.result.success {
  background: rgba(52, 199, 89, 0.1);
  color: #248a3d;
}

.result.error {
  background: rgba(255, 59, 48, 0.1);
  color: #d70015;
}

.download-section {
  display: none;
  margin-top: 16px;
}

.download-section.show {
  display: block;
}

/* Icon Grid */
.icon-grid-section {
  display: none;
  margin-top: 32px;
}

.icon-grid-section.show {
  display: block;
}

.icon-grid-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
}

.icon-card {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  transition: all 0.2s ease;
}

.icon-card:hover {
  background: #f0f0f0;
}

.icon-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.icon-download-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px var(--shadow);
}

.icon-card:hover .icon-download-btn {
  opacity: 1;
}

.icon-download-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.icon-download-btn:hover svg {
  stroke: #fff;
}

.icon-download-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--muted);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Helper Text */
.helper {
  margin-bottom: 32px;
}

.helper-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.helper-text {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.helper-list {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.8;
  padding-left: 20px;
  margin: 0;
}

.helper-list li {
  margin-bottom: 4px;
}

.helper-list em {
  color: var(--fg);
  font-style: normal;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.helper-limits {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  opacity: 0.7;
}

.helper-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

.helper-option label {
  font-weight: 500;
}

.helper-option input[type="number"] {
  width: 64px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--fg);
  text-align: center;
}

.helper-option input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.1);
}

.helper-option-hint {
  font-size: 13px;
  opacity: 0.7;
}

.color-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  padding: 4px 10px 4px 6px;
  border-radius: 6px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.color-badge:hover {
  background: #fdf4ff;
  border-color: rgba(217, 70, 239, 0.3);
}

.color-badge.copied::after {
  content: 'Copied!';
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  animation: fadeOut 1.5s ease forwards;
}

@keyframes fadeOut {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.color-swatch {
  width: 14px;
  height: 14px;
  background: #ff00ff;
  border-radius: 3px;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 64px;
}

.footer-text {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.footer-link {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--accent);
}

.footer-cta {
  margin-bottom: 32px;
}

.footer-built {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 48px 20px 80px;
  }

  .headline {
    font-size: 40px;
  }

  .subtitle {
    font-size: 18px;
    margin-bottom: 40px;
  }

  .upload-card {
    padding: 24px;
  }

  .upload-area {
    padding: 48px 24px;
  }

  .upload-icon {
    width: 48px;
    height: 48px;
  }

  .icon-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
  }

  .icon-card {
    padding: 8px;
    border-radius: 8px;
  }

  .icon-download-btn {
    opacity: 1;
    width: 24px;
    height: 24px;
    bottom: 4px;
    right: 4px;
  }

  .icon-download-btn svg {
    width: 12px;
    height: 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover:not(:disabled) {
    transform: none;
  }
  .btn-primary:active:not(:disabled) {
    transform: none;
  }
}
