:root {
  --bg-top: #f7f1e7;
  --bg-bottom: #e5d5bf;
  --ink: #2b2119;
  --ink-muted: #6c5a4b;
  --surface-glass: rgba(255, 250, 244, 0.78);
  --surface-dark: rgba(34, 26, 20, 0.84);
  --border-light: rgba(255, 255, 255, 0.65);
  --accent: #c67d5b;
  --ok: #34c759;
  --warn: #ff9f0a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 50% 35%, var(--bg-top) 0%, var(--bg-bottom) 100%);
  user-select: none;
  -webkit-user-select: none;
}

.studio {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.studio__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.studio__canvas:active {
  cursor: grabbing;
}

/* Hand cursor */
.hand-cursor {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hand-cursor__ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(244, 184, 200, 0.45);
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.hand-cursor__ring::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
}

.hand-cursor.is-pinching .hand-cursor__ring {
  transform: scale(1.65);
  background: rgba(198, 125, 91, 0.72);
}

.hand-cursor .hand-cursor__ring { border-color:#83d5fc; background:#83d5fc48; }
.hand-cursor.is-pinching .hand-cursor__ring { border-color:#ff6965; background:#ff696560; }
.hand-cursor__label {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-dark);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.studio #hand-cursor.is-pinching.is-pressing-clay .hand-cursor__ring {
  transform: scale(1.78);
  border-color: #ffe4c2;
  box-shadow: 0 0 0 3px #ff846755, 0 0 15px #ff654bab;
}

.clay-pressure {
  position: fixed;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  white-space: nowrap;
  padding: 5px 8px;
  border: 1px solid #f3ab7459;
  border-radius: 6px;
  background: #211710f5;
  color: #ffebd8;
  box-shadow: 0 2px 10px #0005;
  font: 12px/1.25 system-ui, sans-serif;
}
.clay-pressure__title { color: #f2bf96; }
.clay-pressure__meter { display: flex; align-items: flex-end; gap: 2px; }
.clay-pressure__meter i { width: 4px; height: 5px; border-radius: 1px; background: #754f38; }
.clay-pressure__meter i:nth-child(2) { height: 8px; }
.clay-pressure__meter i:nth-child(3) { height: 11px; }
.clay-pressure__meter i:first-child,
.clay-pressure:is([data-level="2"],[data-level="3"]) i:nth-child(2),
.clay-pressure[data-level="3"] i:last-child { background: #ffba79; }

@media (prefers-reduced-motion: reduce) {
  .hand-cursor__ring { transition: none; }
}

/* Right-side vertical glaze palette */
.palette {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  padding: 10px 8px;
  border-radius: 999px;
  background: var(--surface-glass);
  border: 1px solid var(--border-light);
  box-shadow: 0 10px 30px rgba(43, 33, 25, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.palette__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.palette__swatch {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5), 0 2px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.palette__swatch:hover {
  transform: scale(1.1);
}

.palette__swatch.is-selected {
  transform: scale(1.18);
  border-color: #ffffff;
  box-shadow: 0 0 0 2.5px var(--ink), 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Bottom-left webcam card */
.cam-card {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 210px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-glass);
  border: 1px solid var(--border-light);
  box-shadow: 0 12px 28px rgba(43, 33, 25, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.cam-card__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #231c17;
  overflow: hidden;
}

.cam-card__video,
.cam-card__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-card__video {
  transform: scaleX(-1);
}

.cam-card__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background: rgba(35, 28, 23, 0.85);
  color: #f5efe6;
}

.cam-card__fallback-text {
  font-size: 12px;
  line-height: 1.35;
}

.cam-card__retry {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cam-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.cam-card__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}

.cam-card__dot.is-active {
  background: var(--ok);
}

/* Bottom-center controls & hint */
.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.shape-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--surface-glass);
  border: 1px solid var(--border-light);
  box-shadow: 0 8px 20px rgba(43, 33, 25, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.shape-pill {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.shape-pill:hover {
  background: rgba(43, 33, 25, 0.08);
}

.shape-pill.is-active {
  background: var(--ink);
  color: #fff;
}

.hint-pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

@media (max-width: 720px) {
  .cam-card {
    width: 136px;
    left: max(10px, env(safe-area-inset-left));
    bottom: max(116px, env(safe-area-inset-bottom));
  }

  .palette {
    right: max(10px, env(safe-area-inset-right));
    padding: 8px 6px;
  }

  .palette__swatch {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
  }

  .hint-pill {
    font-size: 12px;
    padding: 7px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
