:root {
  --gold: #d9b24a;
  --gold-dark: #a8842e;
  --ink: #221a10;
  --bg: #faf7f0;
  --card: #ffffff;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: var(--card);
  border-bottom: 1px solid #e8e0cc;
}
.logo { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.5px; }
.logo span { color: var(--gold-dark); }
nav a { margin-left: 18px; color: var(--ink); text-decoration: none; font-weight: 600; }
nav a:hover { color: var(--gold-dark); }

.hero {
  text-align: center; padding: 56px 20px 40px;
  background: linear-gradient(160deg, #fdf6e3, #f6e8c8);
}
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); }
.hero h1 em { color: var(--gold-dark); font-style: normal; }
.hero p { margin: 12px 0 24px; color: #5c5340; }

.primary {
  background: var(--gold); color: #fff; border: none; cursor: pointer;
  padding: 12px 26px; border-radius: 10px; font-size: 1.05rem; font-weight: 700;
  text-decoration: none; display: inline-block;
}
.primary:hover { background: var(--gold-dark); }
.primary:disabled { background: #cfc6b3; cursor: not-allowed; }

.ghost {
  background: transparent; color: var(--ink); cursor: pointer;
  padding: 12px 20px; border-radius: 10px; font-size: 1rem; font-weight: 600;
  border: 1.5px solid #cbbd9d; text-decoration: none; display: inline-block;
}
.ghost:disabled { opacity: 0.5; cursor: not-allowed; }

.steps { display: flex; gap: 14px; justify-content: center; padding: 26px 20px; flex-wrap: wrap; }
.step {
  background: var(--card); border: 1px solid #e8e0cc; border-radius: 12px;
  padding: 14px 20px; display: flex; align-items: center; gap: 10px;
}
.step b {
  background: var(--gold); color: #fff; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
}

#studio {
  display: grid; grid-template-columns: 1fr 300px; gap: 20px;
  max-width: 1100px; margin: 0 auto 40px; padding: 0 16px;
}

.stage {
  position: relative; border-radius: 14px; overflow: hidden;
  background: #141210;
  height: min(72vh, 680px);          /* fit any screen: portrait or landscape */
  display: flex; align-items: center; justify-content: center;
}
.stage canvas {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;         /* keeps camera aspect — no stretch, no crop */
  display: block; touch-action: none; cursor: default;
}
.offscreen { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

.stage-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem; text-align: center; padding: 20px;
  background: rgba(20, 18, 16, 0.55);
  pointer-events: none; /* never block canvas interaction */
}
.status {
  position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.55);
  color: #ffe9b0; padding: 6px 12px; border-radius: 999px; font-size: 0.85rem;
  pointer-events: none;
}
.controls { display: flex; gap: 10px; margin-top: 12px; }

.catalog { background: var(--card); border: 1px solid #e8e0cc; border-radius: 14px; padding: 16px; align-self: start; }
.catalog h2 { font-size: 1.1rem; margin-bottom: 10px; }
.catalog h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: #8a7d5f; margin: 12px 0 8px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs button {
  border: 2px solid #e8e0cc; background: #fdfaf2; border-radius: 10px;
  padding: 6px; cursor: pointer;
}
.thumbs button img { width: 100%; height: 64px; object-fit: contain; }
.thumbs button.selected { border-color: var(--gold); background: #fdf3d7; }
.thumbs button span { display: block; font-size: 0.68rem; margin-top: 4px; font-weight: 600; }
.thumbs button { position: relative; }
.thumb-del {
  position: absolute; top: 2px; right: 4px; font-style: normal; cursor: pointer;
  color: #b0483f; font-weight: 700; font-size: 0.75rem; padding: 2px 4px;
  opacity: 0.35; border-radius: 4px;
}
.thumbs button:hover .thumb-del { opacity: 1; }
.thumb-del:hover { background: #fbe3e0; }

.cat-add { display: flex; gap: 8px; margin-bottom: 4px; }
.chip {
  background: #fdf3d7; border: 1.5px solid var(--gold); color: var(--gold-dark);
  border-radius: 999px; padding: 6px 12px; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.chip:hover { background: var(--gold); color: #fff; }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
.restore { display: inline-block; margin-top: 14px; color: #8a7d5f; font-size: 0.8rem; }
.fit-bar { align-items: center; }
.fit-hint { font-size: 0.78rem; color: #8a7d5f; margin-right: auto; }
.slider { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #5c5340; font-weight: 600; }
.slider input[type="range"] { width: 110px; accent-color: var(--gold-dark); }

.modal {
  position: fixed; inset: 0; background: rgba(20, 18, 16, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border-radius: 14px; padding: 20px; max-width: 480px; width: 100%; }
.modal-card h2 { margin-bottom: 12px; }
.modal-card img { width: 100%; border-radius: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

footer { text-align: center; padding: 24px; color: #8a7d5f; font-size: 0.85rem; }

@media (max-width: 800px) {
  #studio { grid-template-columns: 1fr; }
  .catalog { order: 2; }
}
