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

body {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  background: #1a1a1a;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ── Shell ──────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}
header h1 { font-size: 1.1rem; font-weight: 600; color: #fff; }
header p  { font-size: 0.75rem; color: #888; margin-top: 0.15rem; }
header .attribution {
  font-size: 0.7rem;
  color: #666;
  margin-top: 0.25rem;
}
header .attribution a { color: #7aaa7a; text-decoration: none; }
header .attribution a:hover { text-decoration: underline; }

main { display: flex; flex: 1; min-height: 0; }

/* ── Sidebar ────────────────────────────────────────────────────── */
#controls {
  width: 230px;
  min-width: 230px;
  background: #222;
  border-right: 1px solid #333;
  padding: 0.9rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

section { display: flex; flex-direction: column; gap: 0.35rem; }

section h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 0.1rem;
}

label { font-size: 0.72rem; color: #aaa; margin-top: 0.2rem; }

input[type="number"], select {
  width: 100%;
  padding: 0.3rem 0.45rem;
  background: #2c2c2c;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
}
input[type="number"]:focus, select:focus { border-color: #666; }

/* ── Upload area ────────────────────────────────────────────────── */
.upload-area {
  position: relative;
  border: 2px dashed #444;
  border-radius: 6px;
  padding: 0.9rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: #6a9a6a;
  background: #252525;
}
.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-area .hint {
  font-size: 0.72rem;
  color: #888;
  pointer-events: none;
}
.upload-area .hint strong { color: #aaa; display: block; margin-bottom: 0.1rem; }

#previewThumb {
  display: none;
  width: 100%;
  max-height: 80px;
  object-fit: cover;
  border-radius: 3px;
  margin-top: 0.4rem;
  border: 1px solid #444;
}

/* ── p/q/r row ──────────────────────────────────────────────────── */
.pqr-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}
.pqr-field { display: flex; flex-direction: column; gap: 0.15rem; }
.pqr-field span { font-size: 0.65rem; color: #666; text-align: center; }
.pqr-field input { padding: 0.3rem 0.2rem; text-align: center; }

/* ── Preset chips ───────────────────────────────────────────────── */
.presets { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  padding: 0.2rem 0.5rem;
  border: 1px solid #444;
  border-radius: 3px;
  background: #2c2c2c;
  color: #aaa;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:hover { background: #353535; border-color: #555; color: #ccc; }

/* ── Size grid ──────────────────────────────────────────────────── */
.size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}
.size-btn {
  padding: 0.3rem 0;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2c2c2c;
  color: #aaa;
  font-size: 0.72rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.size-btn:hover { background: #353535; border-color: #555; color: #ccc; }
.size-btn.active { background: #2c3e2c; border-color: #4a7a4a; color: #cce8cc; }

/* ── Hint text ──────────────────────────────────────────────────── */
#paramHint { font-size: 0.7rem; color: #666; line-height: 1.6; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-group { display: flex; flex-direction: column; gap: 0.35rem; }

.btn {
  width: 100%;
  padding: 0.45rem 0;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2c2c2c;
  color: #e0e0e0;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: #383838; border-color: #555; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: #2c3e2c; border-color: #4a7a4a; color: #cce8cc; }
.btn.primary:hover:not(:disabled) { background: #364836; }

/* ── Canvas area ────────────────────────────────────────────────── */
#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  position: relative;
  min-width: 0;
}

#artCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  border: 1px solid #333;
  background: #000;
}

/* ── Progress overlay ───────────────────────────────────────────── */
#progressOverlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
#progressOverlay.visible { display: flex; }

#progressBar {
  width: min(280px, 55%);
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  width: 0%;
  background: #4a7a4a;
  border-radius: 3px;
  transition: width 0.1s linear;
}
#progressLabel { font-size: 0.78rem; color: #aaa; }

/* ── Status bar ─────────────────────────────────────────────────── */
#statusBar {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: #555;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
#controls::-webkit-scrollbar { width: 5px; }
#controls::-webkit-scrollbar-track { background: #1a1a1a; }
#controls::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
