/* ========================================================================
   Graph Digitizer — Dark Mode Theme
   ======================================================================== */

:root {
  --bg:          #0f1117;
  --bg-surface:  #1a1d27;
  --bg-card:     #222636;
  --bg-hover:    #2a2f42;
  --border:      #2e3348;
  --text:        #e1e4ed;
  --text-muted:  #8a90a5;
  --text-dim:    #5c6178;
  --accent:      #6c8cff;
  --accent-glow: rgba(108, 140, 255, 0.25);
  --accent-dim:  #4a6ad4;
  --success:     #4ade80;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --radius:      10px;
  --radius-sm:   6px;
}

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

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

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* --- Header --- */

header {
  text-align: center;
  padding: 24px 0 8px;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* --- Stepper --- */

#stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 0 28px;
  overflow-x: auto;
}

.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: default;
  flex-shrink: 0;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-dim);
  transition: all 0.3s ease;
}

.step-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: color 0.3s ease;
}

.step-connector {
  width: 32px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  margin-bottom: 20px;
  transition: background 0.3s ease;
}

/* Stepper states */
.step-indicator.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.step-indicator.active .step-label {
  color: var(--accent);
  font-weight: 600;
}

.step-indicator.done .step-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.step-indicator.done .step-label {
  color: var(--success);
}

.step-connector.done {
  background: var(--success);
}

/* --- Main content --- */

main {
  min-height: 500px;
}

.step-panel {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-panel.hidden {
  display: none;
}

.step-header {
  margin-bottom: 20px;
}

.step-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.step-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.step-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
  margin-top: 8px;
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-back {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-back:hover {
  background: var(--bg-card);
  color: var(--text);
}

.btn-group {
  display: flex;
  gap: 10px;
}

/* --- Step navigation --- */

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* --- Cards --- */

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.info-card h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.info-card.centered {
  text-align: center;
  max-width: 500px;
  margin: 40px auto;
}

/* --- Drop zone (Step 1) --- */

#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-surface);
}

#drop-zone:hover, #drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.05);
}

.drop-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.drop-or {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 8px 0;
}

#step1-preview {
  margin-top: 16px;
  text-align: center;
}

#step1-preview canvas {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* --- Canvas containers --- */

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: crosshair;
}

.canvas-wrap.centered {
  max-width: 800px;
  margin: 0 auto;
}

.canvas-wrap canvas, .canvas-panel canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Side-by-side layout --- */

.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.canvas-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.canvas-panel h3 {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.canvas-panel canvas {
  display: block;
  width: 100%;
  cursor: default;
}

/* --- Step 2 layout --- */

.step2-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
}

.step2-sidebar {
  display: flex;
  flex-direction: column;
}

#step2-zoom {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  image-rendering: pixelated;
}

#color-swatch {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

#color-stats {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre;
  margin: 0;
}

/* --- Step 4 layout --- */

.step4-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
}

.step4-sidebar {
  display: flex;
  flex-direction: column;
}

.step4-sidebar .info-card {
  overflow: visible;
}

#step4-prompt {
  color: var(--accent);
}

.cal-point {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.cal-point:last-child { border-bottom: none; }

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-point input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  -moz-appearance: textfield;
}

/* Hide native number spinners */
.cal-point input::-webkit-outer-spin-button,
.cal-point input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cal-point input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* --- Axis format selectors (Step 4) --- */

.axis-format-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.axis-format-row label {
  color: var(--text-muted);
  min-width: 50px;
}

.axis-format-row select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a90a5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.axis-format-row select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* --- Slider (Step 5) --- */

.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.slider-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.slider-row span {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 3em;
}

/* --- Brush info (Step 6) --- */

.brush-info {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Step 6 mask canvas cursor */
#step6-mask {
  cursor: none;
}

/* --- Progress bar (Step 7) --- */

#step7-progress-wrap {
  max-width: 500px;
  margin: 40px auto;
  text-align: center;
}

.progress-bar {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 4px;
  transition: width 0.1s ease;
}

#step7-status {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* --- Footer --- */

footer {
  text-align: center;
  padding: 32px 0 16px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* --- Utilities --- */

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  .step2-layout, .step4-layout { grid-template-columns: 1fr; }
  .side-by-side { grid-template-columns: 1fr; }
  #stepper { gap: 0; }
  .step-connector { width: 16px; }
  .step-label { display: none; }
}
