:root{
  --sand: #E8D9C2;
  --paper: #F1E5D1;
  --ink: #241D17;
  --terracotta: #B0532A;
  --terracotta-deep: #8A4222;
  --clay: #6E5640;
  --hairline: #CDB48C;
}

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

body{
  background:var(--sand);
  color:var(--ink);
  font-family:'Inter', sans-serif;
  padding:28px 16px 60px;
}

.page{ max-width:1100px; margin:0 auto; }

.page-head{ text-align:center; margin-bottom:28px; }
.page-head h1{ font-size:1.7rem; margin-bottom:6px; }
.subtitle{ color:var(--clay); font-size:14px; }

.layout{
  display:grid;
  grid-template-columns: 1fr 360px;
  gap:24px;
  align-items:flex-start;
}

@media (max-width: 820px){
  .layout{ grid-template-columns: 1fr; }
}

/* ---------- PREVIEW ---------- */
.preview-panel{
  background:var(--paper);
  border:1px solid var(--hairline);
  border-radius:16px;
  padding:24px;
  position:sticky;
  top:20px;
}

.preview-stage{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:160px;
  background:
    linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%),
    linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  border-radius:10px;
  padding:20px;
  margin-bottom:16px;
}

#previewCanvas{
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.preview-actions{ display:flex; flex-direction:column; gap:8px; }

.action-buttons{ display:flex; gap:10px; margin-top:8px; }

.btn{
  flex:1;
  padding:11px 16px;
  border-radius:10px;
  font-size:13.5px;
  font-weight:600;
  border:none;
  cursor:pointer;
  font-family:inherit;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn-primary{ background:var(--terracotta); color:var(--paper); }
.btn-primary:hover{ background:var(--terracotta-deep); transform:translateY(-1px); }
.btn-ghost{ background:transparent; border:1.5px solid var(--hairline); color:var(--ink); }
.btn-ghost:hover{ border-color:var(--terracotta); color:var(--terracotta-deep); }

/* ---------- CONTROLS ---------- */
.controls-panel{ display:flex; flex-direction:column; gap:16px; }

.control-group{
  background:var(--paper);
  border:1px solid var(--hairline);
  border-radius:14px;
  padding:18px 20px;
}

.control-group h2{
  font-size:14px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--terracotta-deep);
  margin-bottom:14px;
  font-weight:600;
}

.field-label{
  display:block;
  font-size:12.5px;
  color:var(--clay);
  margin: 10px 0 5px;
}

input[type="text"],
input[type="number"],
select{
  width:100%;
  padding:9px 11px;
  border-radius:8px;
  border:1.5px solid var(--hairline);
  background:var(--sand);
  color:var(--ink);
  font-family:inherit;
  font-size:13.5px;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus{
  outline:none;
  border-color:var(--terracotta);
}

input[type="file"]{
  width:100%;
  padding:8px;
  border-radius:8px;
  border:1.5px dashed var(--hairline);
  background:var(--sand);
  color:var(--clay);
  font-family:inherit;
  font-size:12.5px;
}

.hint{
  font-size:11.5px;
  color:var(--clay);
  opacity:0.85;
  margin-top:4px;
  line-height:1.4;
}

.size-readout{
  font-family:'JetBrains Mono', monospace;
  color:var(--terracotta-deep);
  font-weight:500;
  margin-top:6px;
}

.symbol-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap:4px;
  max-height:180px;
  overflow-y:auto;
  margin-top:8px;
  padding:6px;
  border:1.5px solid var(--hairline);
  border-radius:8px;
  background:var(--sand);
}

.symbol-btn{
  aspect-ratio: 1;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:17px;
  border:1px solid transparent;
  border-radius:6px;
  background:var(--paper);
  cursor:pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.symbol-btn:hover{
  background:var(--hairline);
  transform:scale(1.08);
}
.symbol-btn.selected{
  border-color:var(--terracotta);
  background:var(--terracotta);
  color:var(--paper);
}

#symbolSelectedPreview{
  font-weight:600;
  color:var(--terracotta-deep);
  font-size:15px;
}

input[type="color"]{
  width:100%;
  height:38px;
  border-radius:8px;
  border:1.5px solid var(--hairline);
  cursor:pointer;
  background:var(--sand);
}

input[type="range"]{ width:100%; accent-color: var(--terracotta); }

.checkbox-row{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13.5px;
  margin:10px 0 4px;
  cursor:pointer;
}
.checkbox-row input{ accent-color: var(--terracotta); width:16px; height:16px; }

.checkbox-row input:disabled{ cursor:not-allowed; opacity:0.5; }
.checkbox-row:has(input:disabled){ opacity:0.55; cursor:not-allowed; }

.hidden{ display:none; }

footer{
  text-align:center;
  margin-top:40px;
  color:var(--clay);
  font-size:12.5px;
}
