/* ============ Muse — a meditative colouring practice ============ */

:root {
  --bg: #F2EBDF;
  --bg-deep: #E9DFCC;
  --ink: #2E2620;
  --ink-soft: #6B5F4F;
  --ink-faint: #97896F;
  --gold: #B08D57;
  --gold-deep: #9A7743;
  --gold-soft: #D8BE93;
  --sage: #8FA187;
  --paper: #FDFBF7;
  --glass: rgba(253, 251, 247, 0.55);
  --line: rgba(46, 38, 32, 0.12);
  --shadow-soft: 0 12px 40px rgba(70, 55, 35, 0.12);
  --shadow-deep: 0 24px 70px rgba(70, 55, 35, 0.22);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  --sans: "Jost", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-weight: 300;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 50% -8%, #F8F2E7 0%, rgba(248, 242, 231, 0) 60%),
    radial-gradient(900px 600px at 85% 105%, #EDE2CC 0%, rgba(237, 226, 204, 0) 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
[hidden] { display: none !important; }

::selection { background: var(--gold-soft); color: var(--ink); }

/* ============ Hero ============ */

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 28px 80px;
  transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-spring), filter 0.5s var(--ease-out);
}

#app.recede {
  opacity: 0;
  transform: scale(0.96);
  filter: blur(6px);
  pointer-events: none;
}

.hero { text-align: center; margin-bottom: 44px; }

.ornament {
  color: var(--gold);
  font-size: 15px;
  letter-spacing: 0.6em;
  margin-bottom: 10px;
  animation: shimmer 7s ease-in-out infinite;
}

.brand {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(64px, 10vw, 108px);
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.brandLogo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
}

.brandLogo img {
  display: block;
  width: min(680px, 78vw);
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(46, 38, 32, 0.05));
}

.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 2.4vw, 23px);
  color: var(--ink-soft);
  margin-top: 10px;
  letter-spacing: 0.08em;
}

.breath {
  margin-top: 26px;
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-faint);
  animation: breathe 9s ease-in-out infinite;
}
.breath span { color: var(--gold); }

@keyframes breathe {
  0%, 100% { opacity: 0.45; letter-spacing: 0.42em; }
  50% { opacity: 1; letter-spacing: 0.52em; }
}
@keyframes shimmer {
  0%, 100% { opacity: 0.55; } 50% { opacity: 1; }
}

/* ============ Glass surfaces ============ */

.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 253, 248, 0.38));
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  border-radius: 24px;
}

/* ============ Intro / login ============ */

.intro {
  max-width: 620px;
  margin: 0 auto 64px;
  padding: 38px 44px 34px;
  text-align: center;
}

.intro h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.intro > p {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

#loginBlock label {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.loginRow {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

#nameInput {
  width: 240px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  font-size: 15px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: box-shadow 0.3s var(--ease-out), border-color 0.3s;
}
#nameInput:focus {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 4px rgba(176, 141, 87, 0.15);
}

.greet {
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  color: var(--ink);
}
.greet b { color: var(--gold-deep); font-weight: 600; }

/* ============ Buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.35s var(--ease-out), background 0.3s;
}
.btn:active { transform: scale(0.96); }

.btn.gold {
  background: linear-gradient(170deg, #CBA76F, var(--gold) 55%, var(--gold-deep));
  color: #FFF9EC;
  box-shadow: 0 8px 24px rgba(154, 119, 67, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn.gold:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(154, 119, 67, 0.42), inset 0 1px 0 rgba(255,255,255,.45); }

.btn.ghost {
  color: var(--ink-faint);
  font-size: 12px;
  padding: 8px 14px;
}
.btn.ghost:hover { color: var(--ink-soft); }
.btn.ghost.small { font-size: 11px; }

/* ============ Gallery ============ */

.gallerySec { text-align: center; }

.galleryTitle {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(26px, 3.6vw, 34px);
  letter-spacing: 0.05em;
}

.galleryHint {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 10px 0 34px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 26px;
  text-align: left;
}

.card {
  position: relative;
  border-radius: 22px;
  padding: 14px 14px 16px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.75), rgba(255, 252, 244, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px) saturate(1.25);
  -webkit-backdrop-filter: blur(10px) saturate(1.25);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease-spring), box-shadow 0.55s var(--ease-out);
  will-change: transform;
  opacity: 0;
  animation: cardIn 0.9s var(--ease-out) forwards;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(26px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.card:hover {
  box-shadow: var(--shadow-deep);
}

/* liquid-glass specular highlight that follows the pointer */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%),
              rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.08) 42%, transparent 65%);
  opacity: 0;
  transition: opacity 0.45s var(--ease-out);
  pointer-events: none;
  mix-blend-mode: soft-light;
}
.card:hover::after { opacity: 1; }

.thumb {
  position: relative;
  border-radius: 15px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 10px rgba(70, 55, 35, 0.06);
  overflow: hidden;
  aspect-ratio: 1;
}
.thumb svg { display: block; width: 100%; height: 100%; }

.cardMeta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 4px 0;
}

.cardTitle {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.03em;
}

.cardTag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 2;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.badge.done { background: rgba(176, 141, 87, 0.92); color: #FFF9EC; box-shadow: 0 4px 14px rgba(154,119,67,.4); }
.badge.wip { background: rgba(143, 161, 135, 0.88); color: #F7FAF5; }

.card.justSealed .thumb { animation: sealedGlow 1.6s var(--ease-out); }
@keyframes sealedGlow {
  0% { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 0 rgba(176, 141, 87, 0.55); }
  60% { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 26px rgba(176, 141, 87, 0); }
  100% { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 0 rgba(176, 141, 87, 0); }
}

.foot {
  margin-top: 70px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ============ Studio ============ */

.studio {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 600px at 50% -10%, #F8F2E7 0%, rgba(248, 242, 231, 0) 60%),
    var(--bg);
  opacity: 0;
  transition: opacity 0.45s var(--ease-out);
}
.studio.open { opacity: 1; }

.studioBar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  margin: 12px 14px;
  border-radius: 18px;
  z-index: 5;
  transition: transform 0.6s var(--ease-spring), opacity 0.5s var(--ease-out);
}
.studio:not(.open) .studioBar.top { transform: translateY(-24px); opacity: 0; }
.studio:not(.open) .studioBar.bottom { transform: translateY(24px); opacity: 0; }

.studioBar.bottom {
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  padding: 12px 18px 14px;
}

.studioTitle { flex: 1; min-width: 0; line-height: 1.15; }
.studioTitle span {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.03em;
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.studioTitle small {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
}

.barGroup { display: flex; align-items: center; gap: 7px; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }

.iconBtn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 8px rgba(70, 55, 35, 0.07);
  transition: transform 0.3s var(--ease-spring), background 0.25s, color 0.25s, box-shadow 0.3s;
}
.iconBtn svg { width: 18px; height: 18px; }
.iconBtn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.75); color: var(--ink); }
.iconBtn:active { transform: scale(0.93); }
.iconBtn:disabled { opacity: 0.35; pointer-events: none; }
.iconBtn.wide { width: auto; padding: 0 12px; font-size: 12px; letter-spacing: 0.08em; }

.stageWrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.stage {
  width: min(82vmin, calc(100vh - 250px));
  min-width: 280px;
  aspect-ratio: 1;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(70, 55, 35, 0.22), 0 4px 18px rgba(70, 55, 35, 0.12), inset 0 0 0 1px var(--line);
  transition: opacity 0.4s var(--ease-out);
  will-change: transform;
}
.stage svg { display: block; width: 100%; height: 100%; border-radius: 18px; }

/* per-tool cursors + hit rules */
.stage svg .br path, .stage svg .ln path { pointer-events: none; }
.stage svg .rg path { pointer-events: visiblePainted; }
.stage svg[data-tool="erase"] .br path { pointer-events: visibleStroke; }
.stage svg[data-tool="fill"] { cursor: crosshair; }
.stage svg[data-tool="brush"], .stage svg[data-tool="erase"] { cursor: crosshair; }
.stage svg[data-tool="pick"] { cursor: copy; }
.stage svg[data-tool="pan"] { cursor: grab; }
.stage svg[data-tool="pan"]:active { cursor: grabbing; }

/* ============ Tools row ============ */

.toolsRow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }

.tools { display: flex; align-items: flex-start; gap: 6px; }

.brushToolStack { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brushScopeControl {
  position: relative;
  width: 60px;
  height: 24px;
  z-index: 26;
}
.brushScopeControl[hidden] { display: none; }
.brushScopeBtn,
.brushScopeChoice {
  border: 1px solid rgba(176, 141, 87, 0.28);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.78), rgba(255,255,255,.34)),
    rgba(246, 239, 226, 0.46);
  -webkit-backdrop-filter: blur(15px) saturate(1.45);
  backdrop-filter: blur(15px) saturate(1.45);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.88),
    inset 0 -1px 0 rgba(176,141,87,.08),
    0 5px 16px rgba(70,55,35,.13);
  color: var(--ink-soft);
  font-size: 9.2px;
  font-weight: 650;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.brushScopeBtn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 24px;
  padding: 0 8px;
  text-align: center;
  transition: opacity .24s ease, transform .42s var(--ease-spring), filter .3s ease, border-color .25s ease;
}
.brushScopeBtn:hover { color: var(--ink); transform: translateY(-1px); }
.brushScopeControl.region .brushScopeBtn { border-color: rgba(176,141,87,.68); color: var(--gold-deep); }
.brushRegionCount {
  position: absolute;
  top: 46px;
  left: calc(50% + 34px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 20%, rgba(255,255,255,.95), rgba(255,255,255,.24) 44%, transparent 72%),
    linear-gradient(145deg, rgba(255,255,255,.72), rgba(216,190,147,.34));
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 5px 16px rgba(70,55,35,.16);
  color: var(--gold-deep);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  animation: countBadgeIn .34s var(--ease-spring) both;
}
.brushRegionCount[hidden] { display: none; }
.brushRegionCount.confirmed { animation: multiGapConfirm .82s var(--ease-spring) both; }
.brushScopeChoices {
  position: absolute;
  top: 0;
  left: 50%;
  display: flex;
  gap: 5px;
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(.74);
  filter: blur(7px);
  transition: opacity .2s ease, transform .44s var(--ease-spring), filter .3s ease;
}
.brushScopeChoice {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  text-align: center;
  transition: transform .44s var(--ease-spring), color .22s ease, background .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.brushScopeChoice:first-child { transform: translateX(28px) scale(.84); }
.brushScopeChoice:last-child { transform: translateX(-28px) scale(.84); }
.brushScopeChoice.selected {
  color: var(--gold-deep);
  border-color: rgba(176,141,87,.72);
  background:
    linear-gradient(145deg, rgba(255,255,255,.9), rgba(221,195,151,.4)),
    rgba(203,167,111,.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.94), 0 5px 15px rgba(154,119,67,.22);
}
.brushScopeControl.expanded .brushScopeBtn {
  opacity: 0;
  pointer-events: none;
  transform: scale(.66);
  filter: blur(5px);
}
.brushScopeControl.expanded .brushScopeChoices {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
  filter: blur(0);
}
.brushScopeControl.expanded .brushScopeChoice { transform: translateX(0) scale(1); }
.gapPairStatus {
  min-width: 62px;
  height: 21px;
  border: 1px solid rgba(176,141,87,.48);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255,255,255,.86), rgba(236,220,191,.42));
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 5px 14px rgba(70,55,35,.14);
  color: var(--gold-deep);
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  animation: liquidRise .42s var(--ease-spring) both;
}
.gapPairStatus[hidden] { display: none; }
.gapPairStatus.settling {
  pointer-events: none;
  animation: confirmSettle .46s var(--ease-out) forwards;
}
.gapPairStatus {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  padding: 0 8px 2px;
  white-space: nowrap;
}
.gapPairStatus b { font-size: 10px; font-variant-numeric: tabular-nums; }
.gapPairStatus i {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 3px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--gold);
  transform-origin: left;
  animation: gapWindow 3s linear forwards;
}
@keyframes liquidRise {
  from { opacity: 0; transform: translateY(-7px) scale(.76); filter: blur(5px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes countBadgeIn {
  from { opacity: 0; transform: scale(.55); filter: blur(4px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes multiGapConfirm {
  0% { transform: scale(.92); }
  44% { transform: scale(1.18); box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 0 0 7px rgba(176,141,87,.12), 0 10px 24px rgba(154,119,67,.22); }
  100% { transform: scale(1); }
}
@keyframes confirmSettle {
  0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translateY(-3px) scale(.96); filter: blur(2px); }
}
@keyframes gapWindow { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.stage svg .rg path.brushTarget {
  stroke: var(--gold);
  stroke-width: 3;
  stroke-opacity: 0.95;
  vector-effect: non-scaling-stroke;
}

.toolBtn {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  transition: transform 0.35s var(--ease-spring), background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.3s;
}
.toolBtn svg { width: 20px; height: 20px; }
.toolBtn:hover { transform: translateY(-3px); color: var(--ink); }
.toolBtn.active {
  background: linear-gradient(170deg, #CBA76F, var(--gold) 60%, var(--gold-deep));
  color: #FFF9EC;
  box-shadow: 0 6px 18px rgba(154, 119, 67, 0.4), inset 0 1px 0 rgba(255,255,255,.4);
}

.sliderGroup { display: flex; align-items: center; gap: 9px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px; height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--gold);
  box-shadow: 0 2px 7px rgba(70, 55, 35, 0.3);
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 1.5px solid var(--gold);
}

/* ============ Colour row ============ */

.colorRow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }

.paletteChips { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.chip {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: all 0.25s var(--ease-out);
}
.chip:hover { color: var(--ink); }
.chip.active { color: var(--gold-deep); border-color: var(--gold-soft); background: rgba(255,255,255,.55); }

/* magnifying swatch dock */
.dock { display: flex; align-items: flex-end; gap: 7px; height: 46px; padding: 0 6px; }
.swatch {
  width: 27px; height: 27px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(70, 55, 35, 0.25), inset 0 1px 2px rgba(255,255,255,.35);
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform 0.16s ease-out, box-shadow 0.25s;
  flex: 0 0 auto;
}
.swatch.sel { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 4.5px var(--gold), 0 4px 12px rgba(70,55,35,.3); }

.currentWrap { display: flex; align-items: center; gap: 9px; }
.currentColor {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 3px 10px rgba(70, 55, 35, 0.3);
}
.wheelBtn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: conic-gradient(#e5533d, #e3a53f, #b9c24a, #56a86f, #4a9cb8, #5f6cc0, #a45fb8, #e5533d);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 3px 10px rgba(70, 55, 35, 0.3);
  transition: transform 0.3s var(--ease-spring);
}
.wheelBtn:hover { transform: scale(1.12) rotate(20deg); }

/* colour wheel popover */
.wheelPop {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 258px;
  padding: 18px;
  border-radius: 20px;
  z-index: 30;
  transform-origin: bottom right;
  animation: popIn 0.4s var(--ease-spring);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.86) translateY(10px); }
  to { opacity: 1; transform: none; }
}
.wheelPop canvas { display: block; margin: 0 auto 12px; cursor: crosshair; border-radius: 50%; }
.wheelPop .sliderGroup { justify-content: space-between; margin-bottom: 8px; }
.wheelPop input[type="range"] { width: 150px; }
.hexRow { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.hexRow input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink);
  outline: none;
}
.hexPreview { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(70,55,35,.3); }

.recentWrap { display: flex; align-items: center; gap: 6px; }
.recentLabel { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.recent { display: flex; gap: 5px; }
.recent .swatch { width: 19px; height: 19px; }

/* ============ Overlays: sheet & seal ============ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(46, 38, 32, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.4s var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay.closing { animation: fadeOut 0.35s var(--ease-out) forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.sheetCard {
  width: min(420px, calc(100vw - 48px));
  padding: 30px 32px;
  text-align: center;
  animation: popIn 0.45s var(--ease-spring);
}
.sheetCard h3 { font-family: var(--serif); font-weight: 600; font-size: 24px; letter-spacing: 0.03em; margin-bottom: 6px; }
.sheetCard p { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-soft); margin-bottom: 22px; }
.sheetCard .btn { width: 100%; justify-content: center; margin-bottom: 10px; }
.sheetCard .btn.plain {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(70, 55, 35, 0.1);
}
.sheetCard .btn.plain:hover { transform: translateY(-2px); }
.sheetCard .btn.danger { background: none; color: #A8433A; font-size: 12px; box-shadow: none; }

.sealPreview {
  width: min(46vmin, 320px);
  aspect-ratio: 1;
  margin: 0 auto 20px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(70, 55, 35, 0.3), inset 0 0 0 1px var(--line);
  position: relative;
}
.sealPreview svg { width: 100%; height: 100%; display: block; border-radius: 16px; }

/* blessing rings during seal animation */
.sealFly {
  position: fixed;
  z-index: 80;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(70, 55, 35, 0.3);
  will-change: transform, width, height;
}
.sealFly svg { width: 100%; height: 100%; display: block; border-radius: inherit; }

.ringPulse {
  position: fixed;
  z-index: 75;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  pointer-events: none;
  animation: ringOut 1.5s var(--ease-out) forwards;
}
@keyframes ringOut {
  from { opacity: 0.85; transform: scale(0.35); }
  to { opacity: 0; transform: scale(1.6); }
}

.spark {
  position: fixed;
  z-index: 82;
  color: var(--gold);
  pointer-events: none;
  animation: sparkFloat 1.5s var(--ease-out) forwards;
  font-size: 14px;
}
@keyframes sparkFloat {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0deg); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(1.15) rotate(120deg); }
}

/* toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  animation: toastIn 0.5s var(--ease-spring), fadeOut 0.5s var(--ease-out) 2.3s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* FLIP clone used for card -> studio transition */
.flipGhost {
  position: fixed;
  z-index: 70;
  background: var(--paper);
  border-radius: 15px;
  box-shadow: var(--shadow-deep);
  overflow: hidden;
  will-change: transform;
  pointer-events: none;
}
.flipGhost svg { width: 100%; height: 100%; display: block; }

/* ============ Responsive ============ */

@media (max-width: 720px) {
  #app { padding: 36px 16px 60px; }
  .intro { padding: 28px 22px; }
  .toast {
    bottom: calc(350px + env(safe-area-inset-bottom));
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: 18px;
    text-align: center;
    line-height: 1.45;
    letter-spacing: .1em;
  }
  .studioBar { margin: 8px; padding: 8px 10px; gap: 8px; }

  .studioBar.top {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
  }
  .studioBar.top > #backBtn { grid-column: 1; grid-row: 1; }
  .studioBar.top .studioTitle {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: baseline;
    gap: 0.42em;
    min-width: 0;
    padding: 4px 8px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.34);
    white-space: nowrap;
    overflow: hidden;
  }
  .studioBar.top .studioTitle span {
    display: inline;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
  }
  .studioBar.top .studioTitle small {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 12px;
  }
  .studioBar.top .barGroup {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(38px, 52px) minmax(38px, 52px) repeat(4, 32px) 60px;
    justify-content: space-between;
    align-items: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
  }
  .studioBar.top .sep { display: none; }
  .studioBar.top .iconBtn {
    width: 100%;
    min-width: 0;
    height: 34px;
  }
  .studioBar.top #zoomReset { padding: 0; }
  .studioBar.top #printBtn {
    width: 100%;
    min-width: 0;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    text-align: center;
    white-space: nowrap;
    font-size: 11px;
    letter-spacing: 0.07em;
  }

  /* Keep palette names compact while preserving every option. */
  .studioBar.bottom .colorRow { min-width: 0; }
  .studioBar.bottom .paletteChips {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    padding: 2px 2px 5px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .studioBar.bottom .paletteChips::-webkit-scrollbar { display: none; }
  .studioBar.bottom .paletteChips .chip {
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .stage { width: min(94vmin, calc(100vh - 300px)); }
  .wheelPop { right: 50%; transform: translateX(50%); transform-origin: bottom center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
