:root {
  --paper: #f5e6a8;
  --ink: #1a1208;
  --panel: #fff6d0;
  --gold: #d4a017;
  --mint: #3ecf9a;
  --muted: #6b5a3c;
  --line: rgba(26, 18, 8, 0.12);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--paper);
}
body.dark {
  --paper: #14100a;
  --ink: #f7efd4;
  --panel: #221a10;
  --muted: #b9a789;
  --line: rgba(247, 239, 212, 0.14);
}
* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(62, 207, 154, 0.18), transparent 42%),
    radial-gradient(circle at 90% 8%, rgba(212, 160, 23, 0.22), transparent 40%),
    var(--paper);
}
header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 16px 8px;
}
.mark { width: 48px; height: 48px; border-radius: 14px; }
header strong { display: block; letter-spacing: 0.02em; }
header span { color: var(--gold); font-size: 13px; }
nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px;
}
nav button, .chips button, .icons button, .primary, #shareBtn, #saveHist, #clearHist {
  border: 0;
  min-height: 42px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
nav button.on, .chips button.on, .icons button.on { background: var(--gold); color: #111; }
.primary { background: var(--mint); color: #062418; font-weight: 700; width: 100%; margin-top: 12px; }
main { padding: 8px 14px 28px; }
h2 { margin: 14px 0 8px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.4; }
.chips, .swatches, .icons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips button { padding: 8px 10px; font-size: 12px; }
.fields label, .row label {
  display: block;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}
.fields input, .fields select, .fields textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.fields textarea { min-height: 88px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.swatches button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}
.icons button {
  width: 64px;
  height: 64px;
  padding: 6px;
  display: grid;
  place-items: center;
}
.icons img { width: 42px; height: 42px; object-fit: contain; }
.stage {
  margin: 10px auto;
  width: min(100%, 320px);
  aspect-ratio: 1;
  padding: 14px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}
#canvas { width: 100%; height: 100%; display: block; border-radius: 12px; }
.actions button { flex: 1; min-width: 90px; }
#histList { list-style: none; padding: 0; margin: 0; }
#histList li {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
#histList img { width: 56px; height: 56px; border-radius: 10px; background: #fff; }
#histList button { padding: 0 10px; }
.switch { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
