@font-face {
  font-family: 'Carlito';
  src: url('_next/static/media/Carlito-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Carlito';
  src: url('_next/static/media/Carlito-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

body {
  font-family: 'Carlito', system-ui, sans-serif;
  background: linear-gradient(135deg, #065774 0%, #042B58 100%);
  min-height: 100vh;
  padding: 20px;
  color: #1f2937;
}

.container { max-width: 720px; margin: 0 auto; }

/* Header */
header {
  text-align: center;
  margin-bottom: 24px;
  color: white;
}
header h1 {
  font-size: 2rem;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
header p {
  margin-top: 6px;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* Navigation */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  transition: color 0.15s;
}
.nav-link:hover { color: #fff; }
.nav-link svg { width: 16px; height: 16px; }

/* Cards */
.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #065774;
  margin-bottom: 16px;
}

/* Form controls */
label.field-label {
  display: block;
  font-weight: 500;
  color: #065774;
  font-size: 13px;
  margin-bottom: 6px;
}

select, input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 2px solid #D3DCDE;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  color: #1f2937;
}
select:focus, input[type="number"]:focus {
  border-color: #EF9B0C;
  box-shadow: 0 0 0 3px rgba(239,155,12,0.2);
}

/* Two-column row */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 480px) {
  .row { grid-template-columns: 1fr; }
}

/* Color stop list */
.color-stops {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.color-stop {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-stop input[type="color"] {
  width: 44px;
  height: 38px;
  border: 2px solid #D3DCDE;
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: white;
}
.color-stop input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-stop input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.color-stop input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: 'Host Grotesk', monospace;
  border: 2px solid #D3DCDE;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}
.color-stop input[type="text"]:focus {
  border-color: #EF9B0C;
  box-shadow: 0 0 0 3px rgba(239,155,12,0.2);
}
.color-stop input[type="text"].invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}
.stop-actions {
  display: flex;
  gap: 4px;
}

/* Icon buttons */
.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.add {
  background: #e9eef0;
  color: #EF9B0C;
}
.icon-btn.add:hover { background: #D3DCDE; }
.icon-btn.remove {
  background: #fee2e2;
  color: #dc2626;
}
.icon-btn.remove:hover { background: #fecaca; }
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.add-stop-row {
  display: flex;
  justify-content: center;
}

/* Preview */
.preview-section { margin-top: 8px; }
.preview-label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.gradient-bar {
  height: 40px;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.swatches {
  display: flex;
  gap: 4px;
}
.swatch {
  flex: 1;
  height: 48px;
  border-radius: 8px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: transform 0.1s;
  cursor: default;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.swatch:hover { transform: scale(1.05); }
.swatch-label {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.85);
  color: #374151;
  white-space: nowrap;
}

/* Grade preview (simulated matrix cells) */
.grade-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.grade-preview-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.grade-cell {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.grade-label {
  font-size: 10px;
  color: #6b7280;
}

/* Presets */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preset-btn {
  padding: 8px 14px;
  border: 2px solid #D3DCDE;
  border-radius: 10px;
  background: white;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #065774;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.preset-btn:hover {
  border-color: #EF9B0C;
  background: #eef1f2;
}
.preset-btn.active {
  border-color: #EF9B0C;
  background: #e9eef0;
}
.preset-swatch {
  width: 48px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Action buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, #EF9B0C 0%, #EA5F21 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(239,155,12,0.3);
}
.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(239,155,12,0.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: #e9eef0;
  color: #065774;
}
.btn-secondary:hover { background: #D3DCDE; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1f2937;
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* JSON output */
.json-output {
  background: #042B58;
  color: #D3DCDE;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
  margin-top: 12px;
  position: relative;
}
.json-output .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #D3DCDE;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.json-output .copy-btn:hover { background: rgba(255,255,255,0.2); }

/* Responsive */
@media (max-width: 600px) {
  body { padding: 12px; }
  header h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .presets { gap: 6px; }
  .preset-btn { padding: 6px 10px; font-size: 12px; }
  .actions { flex-direction: column; }
  .btn { justify-content: center; }
}
