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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-alt: #0f3460;
  --text: #e0e0e0;
  --text-muted: #8899aa;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #2a2a4a;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  height: calc(100vh - 80px);
  overflow: hidden;
}

.image-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow: hidden;
}

.settings-panel {
  padding: 24px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

/* Upload */
[hidden] {
  display: none !important;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 40px;
  width: 100%;
  max-width: 600px;
  text-align: center;
  color: var(--text-muted);
  transition: border-color 0.2s;
}

.upload-zone.drag-over {
  border-color: var(--accent);
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #1a4a80;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
}

.btn-copy {
  background: var(--surface-alt);
  color: var(--text);
  flex: 1;
  font-size: 0.78rem;
  padding: 10px 8px;
}

.btn-copy:hover:not(:disabled) {
  background: #1a4a80;
}

/* Canvas viewport + zoom */
.canvas-viewport {
  position: relative;
  width: 100%;
  max-width: 900px;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  flex: 1;
  min-height: 120px;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-container {
  position: relative;
  transform-origin: 0 0;
  line-height: 0;
  will-change: transform;
}

.canvas-container canvas {
  display: block;
}

#overlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

#overlayCanvas.crop-active {
  pointer-events: auto;
  cursor: crosshair;
}

/* Image toolbar */
.image-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  flex-wrap: wrap;
}

.image-info {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.zoom-level {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 42px;
  text-align: center;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--surface-alt);
}

.crop-controls {
  display: flex;
  gap: 8px;
}

/* Settings */
.settings-group {
  margin-bottom: 20px;
}

.settings-group h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.value-display {
  color: var(--accent);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}

.radio-group label:has(input:checked) {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.radio-group input[type="radio"] {
  display: none;
}

.slider-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.num-input {
  width: 60px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  text-align: center;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Results */
.results-section {
  margin-bottom: 20px;
}

.results-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gradient-preview {
  height: 48px;
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.color-list {
  max-height: 250px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px;
  border: 1px solid var(--border);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.color-row + .color-row {
  border-top: 1px solid var(--border);
}

.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.copy-buttons {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-alt);
  color: var(--text);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  border: 1px solid var(--accent);
}

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

/* Responsive */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .settings-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
}
