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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

.hidden {
  display: none !important;
}

/* ── Drop zone ──────────────────────────────────────────────── */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3.5rem 2rem;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4338ca;
}

.drop-zone-icon {
  font-size: 2rem;
  line-height: 1;
}

.file-label {
  color: #6366f1;
  text-decoration: underline;
  cursor: pointer;
}

.drop-zone.dragover .file-label {
  color: #4338ca;
}

/* ── Preview ────────────────────────────────────────────────── */

.preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

#preview-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  /* Checkerboard shows through transparent 'None' background */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.link-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover {
  color: #4b5563;
}

/* ── Gradient picker ────────────────────────────────────────── */

.controls-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
}

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

.swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
  transition: transform 0.1s, box-shadow 0.1s;
}

.swatch:hover {
  transform: scale(1.12);
}

.swatch.selected {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #4f46e5;
}

.swatch-none {
  background: #f3f4f6;
  font-size: 0.6rem;
  font-weight: 600;
  color: #6b7280;
  border-color: #e5e7eb;
}

.swatch-none.selected {
  border-color: transparent;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #4f46e5;
}

/* Off-screen anchor for MarkerJS2 — rendered but invisible */
#annotate-source {
  position: fixed;
  left: -9999px;
  top: 0;
  max-width: 100vw;
  max-height: 100vh;
}

/* ── Custom background color picker ────────────────────────── */

.bg-color-row {
  margin-top: 0.75rem;
}

.bg-color-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7280;
  padding: 0.35rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}

.bg-color-label:hover {
  border-color: #a5b4fc;
  color: #4338ca;
}

.bg-color-label.active {
  border-color: #4f46e5;
  color: #4338ca;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #4f46e5;
}

.bg-color-label input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

/* ── Action row (Annotate + Download) ───────────────────────── */

.action-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.action-btn {
  padding: 0.7rem 2rem;
  border: 2px solid #4f46e5;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  background: #fff;
  color: #4f46e5;
}

.action-btn:hover {
  background: #eef2ff;
}

.action-btn--primary {
  background: #4f46e5;
  color: #fff;
}

.action-btn--primary:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn--active {
  background: #eef2ff;
  color: #4338ca;
  border-color: #a5b4fc;
}
