:root {
  --ink: #1d1c1b;
  --muted: #6a625c;
  --paper: #fbf7f2;
  --blush: #f3d6c6;
  --butter: #f6e9b2;
  --cocoa: #b07a63;
  --shadow: 0 20px 50px rgba(25, 18, 15, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff6ee 0%, #f3d6c6 35%, #f6e9b2 100%);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 32px 64px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}

h1 {
  font-family: "Fraunces", serif;
  font-size: 40px;
  margin: 0 0 8px;
}

.subhead {
  margin: 0;
  max-width: 560px;
  color: var(--muted);
}

.status {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.panel {
  background: var(--paper);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(176, 122, 99, 0.2);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #fff;
  border-radius: 16px;
  border: 1px dashed rgba(176, 122, 99, 0.4);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
}

.canvas-wrap.dragover {
  border-color: rgba(176, 122, 99, 0.9);
  box-shadow: 0 0 0 3px rgba(176, 122, 99, 0.15);
}

#previewCanvas {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  border-radius: 14px;
  background: #fdfaf6;
  cursor: grab;
  touch-action: none;
}

#previewCanvas.dragging {
  cursor: grabbing;
}

.canvas-overlay {
  position: absolute;
  bottom: 12px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  padding: 6px 10px;
  border-radius: 999px;
}

.controls {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.controls label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.controls input[type="text"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(176, 122, 99, 0.4);
  font-family: inherit;
}

.tile-controls {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed rgba(176, 122, 99, 0.35);
  background: rgba(255, 255, 255, 0.6);
}

.tile-controls .label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.tile-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tile-inputs {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.tile-inputs label {
  display: grid;
  gap: 6px;
  flex: 1 1 120px;
}

.tile-inputs input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(176, 122, 99, 0.4);
  font-family: inherit;
}

.control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

input[type="range"] {
  accent-color: var(--cocoa);
}

button {
  border: none;
  font-family: inherit;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 600;
}

button.primary {
  background: var(--cocoa);
  color: #fff;
}

button.ghost {
  background: transparent;
  color: var(--cocoa);
  border: 1px solid rgba(176, 122, 99, 0.5);
}

.file-upload {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px dashed rgba(176, 122, 99, 0.6);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

.file-upload input {
  display: none;
}

.instructions {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.meta {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.meta .label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-search {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.history-search input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(176, 122, 99, 0.4);
  font-family: inherit;
}

.history-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  background: #fff;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(176, 122, 99, 0.25);
}

.history-card img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: #f4efe9;
}

.history-card .meta {
  margin: 0;
}

.history-card .actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.history-card .queue-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.history-card a.queue-action {
  text-decoration: none;
  color: var(--cocoa);
  border: 1px solid rgba(176, 122, 99, 0.4);
}

.history-card select.queue-action {
  min-width: 92px;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(29, 28, 27, 0.35);
  font-family: inherit;
  cursor: pointer;
}

@media (max-width: 720px) {
  .header {
    flex-direction: column;
  }

  .page {
    padding: 32px 20px 48px;
  }
}
