:root {
  --brand: #b5713a;
  --brand-dark: #8a5227;
  --bg: #f7f3ee;
  --ink: #2b241d;
  --muted: #7a7168;
  --card: #ffffff;
  --border: #e7ddd0;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-icon { font-size: 20px; }
.lang-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

main#stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel.hidden { display: none; }

/* ---------- Welcome ---------- */
#welcome { align-items: center; justify-content: center; padding: 24px; }
.welcome-card {
  max-width: 420px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 24px;
  box-shadow: 0 10px 30px rgba(60, 40, 20, 0.06);
}
.welcome-emoji { font-size: 48px; margin-bottom: 8px; }
.welcome-card h1 { font-size: 22px; margin: 8px 0 10px; }
.welcome-card p { color: var(--muted); font-size: 14.5px; line-height: 1.5; margin: 0 0 22px; }
.welcome-hint { margin-top: 16px !important; font-size: 12.5px !important; color: #a2957f !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--border); }
.btn-big { width: 100%; padding: 15px 18px; font-size: 15.5px; border-radius: 14px; }

.photo-choice-row { display: flex; gap: 10px; }
.photo-choice-row .btn-big { width: auto; flex: 1; padding: 15px 10px; font-size: 14px; }

/* ---------- Editor ---------- */
#editor { min-height: 0; }
.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #111;
  overflow: hidden;
  display: flex;
}
#roomCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.canvas-hint {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  background: rgba(20, 16, 12, 0.72);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  max-width: 88%;
  text-align: center;
  pointer-events: none;
  transition: opacity .3s;
}
.canvas-hint.faded { opacity: 0; }

.mini-btn {
  position: absolute;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #d64545;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
}
.mini-btn.hidden { display: none; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.toolbar .btn { flex: 1 1 calc(50% - 4px); min-width: calc(50% - 4px); padding: 11px 6px; font-size: 12.5px; }

.catalog {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.catalog::-webkit-scrollbar { height: 4px; }

.product-card {
  flex: 0 0 auto;
  width: 88px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 6px 4px 8px;
  transition: border-color .15s, background .15s;
}
.product-card:active { background: var(--bg); }
.product-card.active-flash { border-color: var(--brand); background: #fbf1e6; }
.product-card img {
  width: 72px; height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
}
.product-card .pname {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

.foot {
  text-align: center;
  font-size: 10.5px;
  color: #b6ab9b;
  padding: 6px 0 calc(6px + var(--safe-bottom));
  background: var(--bg);
}

@media (min-width: 720px) {
  .canvas-wrap { max-height: 72vh; }
  body { align-items: center; }
  main#stage { max-width: 480px; margin: 0 auto; width: 100%; box-shadow: 0 0 40px rgba(0,0,0,.06); }
}
