@property --amp { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  --bg: #15120C;
  --s1: #201C14;
  --s2: #2A2419;
  --s3: #3A3224;
  --khaki: #4A402E;
  --tx: #F1EDE0;
  --mut: rgba(241, 237, 224, .5);
  --rasp: #D81E5B;
  --grass: #6DE442;
  --moss: #578901;
  --mint: #0BBA94;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --pebble: 46% 54% 48% 52% / 40% 42% 58% 60%;
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--tx);
  font-family: Nunito, ui-rounded, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
body { background: radial-gradient(120% 70% at 50% 18%, #241E14 0%, var(--bg) 62%); }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

/* ---------- the pond: slow drifting light ---------- */
.pond { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.drift, .glow { position: absolute; border-radius: 50%; will-change: transform, opacity; }
.drift.d1 { width: 70vmax; height: 60vmax; left: -25vmax; top: -10vmax; background: radial-gradient(closest-side, var(--mint), transparent); opacity: .14; animation: drift1 26s ease-in-out infinite alternate; }
.drift.d2 { width: 60vmax; height: 70vmax; right: -30vmax; bottom: -25vmax; background: radial-gradient(closest-side, var(--moss), transparent); opacity: .2; animation: drift2 32s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vmax, 14vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vmax, -20vmax) scale(.9); } }
.glow {
  left: 50%; top: 28dvh;
  width: min(110vw, 520px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: var(--mint);
  background: radial-gradient(closest-side, currentColor, transparent);
  opacity: .16;
  transition: color .9s var(--ease);
}
.glow.hit { animation: glowhit 1.4s var(--ease); }
@keyframes glowhit { 0% { opacity: .4; transform: translate(-50%, -50%) scale(.85); } 100% { opacity: .16; transform: translate(-50%, -50%) scale(1); } }

.app {
  position: relative;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 0; height: 62px; flex: 0 0 auto; }
.brand { font-weight: 900; font-size: 19px; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.brand .seed {
  width: 12px; height: 14px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--grass);
  box-shadow: 0 0 14px var(--grass);
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.18) rotate(8deg); } }
/* major / minor switch */
.modesw {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--s1);
  border-radius: 30px 24px 28px 26px;
  padding: 4px;
}
.modesw button {
  position: relative; z-index: 1;
  height: 44px; padding: 0 13px;
  font-size: 14px; font-weight: 900;
  color: var(--mut);
  transition: color .35s, transform .4s var(--spring);
}
.modesw button:active { transform: scale(.88); }
.modesw button.on { color: var(--bg); }
.mind {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  border-radius: var(--pebble);
  background: var(--mint);
  box-shadow: 0 6px 18px -8px var(--mint);
  transition: transform .6s var(--spring), background .5s;
}
.modesw.minor .mind { transform: translateX(100%); background: var(--rasp); box-shadow: 0 6px 18px -8px var(--rasp); }
.modesw.minor button.on { color: #fff; }

.keypick { display: flex; align-items: center; background: var(--s1); border-radius: 30px 26px 28px 24px; padding: 4px; }
.iconbtn {
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 26px; line-height: 1;
  display: grid; place-items: center;
  padding-bottom: 3px;
  transition: transform .4s var(--spring), background .2s;
}
.iconbtn:active { transform: scale(.8); background: var(--s3); }
.keyname { min-width: 92px; text-align: center; line-height: 1.1; overflow: hidden; }
.keyname small { display: block; font-size: 9px; letter-spacing: .2em; color: var(--mut); font-weight: 800; }
.keyname span { display: inline-block; font-weight: 800; font-size: 16px; }
.keyname span.flip { animation: flip .55s var(--spring); }
@keyframes flip { 0% { transform: translateY(10px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- wheel ---------- */
.stage { position: relative; display: flex; flex-direction: column; align-items: center; padding: 4px 16px 0; flex: 0 0 auto; }

/* view layers inside the one SVG: crossfade with a little bloom */
.view { opacity: 0; transform: scale(.84); pointer-events: none; transition: opacity .45s var(--ease), transform .75s var(--spring); }
.view.on { opacity: 1; transform: none; pointer-events: auto; }

/* view picker */
.viewpick { position: absolute; top: 4px; left: 16px; z-index: 5; }
.vbtn {
  height: 44px; padding: 0 10px 0 12px;
  display: flex; align-items: center; gap: 4px;
  border-radius: var(--pebble);
  background: var(--s2);
  box-shadow: inset 0 0 0 1.5px rgba(241, 237, 224, .1), 0 8px 20px -10px #000;
  color: var(--tx);
  transition: transform .4s var(--spring), background .2s;
}
.vbtn:active { transform: scale(.88); }
.vbtn svg { width: 22px; height: 22px; display: block; }
.vbtn em { font-style: normal; font-size: 11px; color: var(--mut); transition: transform .4s var(--spring); }
.viewpick.open .vbtn em { transform: rotate(180deg); }
.vmenu {
  position: absolute; top: 52px; left: 0;
  width: min(290px, calc(100vw - 32px));
  padding: 6px;
  border-radius: 28px 24px 30px 22px;
  background: var(--s1);
  box-shadow: 0 24px 50px -16px #000, inset 0 0 0 1.5px rgba(241, 237, 224, .08);
  transform-origin: 22px -10px;
  transform: scale(.55) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .5s var(--spring), opacity .25s var(--ease);
}
.viewpick.open .vmenu { transform: none; opacity: 1; pointer-events: auto; }
.vmenu button {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  min-height: 62px;
  border-radius: 22px 18px 22px 16px;
  text-align: left;
  opacity: 0; transform: translateY(-6px);
  transition: background .2s, transform .45s var(--spring), opacity .3s;
}
.viewpick.open .vmenu button { opacity: 1; transform: none; }
.viewpick.open .vmenu button:nth-child(2) { transition-delay: .04s; }
.viewpick.open .vmenu button:nth-child(3) { transition-delay: .08s; }
.vmenu button:active { transform: scale(.96); }
.vmenu button[aria-selected="true"] { background: var(--s3); }
.vmenu i {
  flex: 0 0 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--pebble);
  background: var(--s2);
  color: var(--mint);
}
.vmenu button[aria-selected="true"] i { background: var(--mint); color: var(--bg); }
.vmenu i svg { width: 22px; height: 22px; }
.vmenu b { display: block; font-size: 15px; font-weight: 900; }
.vmenu small { display: block; font-size: 12px; font-weight: 600; color: var(--mut); line-height: 1.3; margin-top: 1px; }

/* symmetry shapes (chromatic clock only) */
.shapes {
  display: none;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
}
.stage[data-view="clock"] .shapes { display: flex; animation: swap .5s var(--ease); }
.shapes button {
  flex: 1 1 auto; height: 40px; padding: 0 8px; white-space: nowrap;
  border-radius: 22px 18px 22px 16px;
  background: var(--s1);
  font-size: 12.5px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: transform .4s var(--spring), background .2s;
}
.shapes button span { color: var(--grass); font-size: 11px; }
.shapes button:active { transform: scale(.9); background: var(--s3); }

/* tonnetz */
.tri { cursor: pointer; transform-box: fill-box; transform-origin: center; }
.tri path { stroke-width: 10; stroke-linejoin: round; transition: fill .45s var(--ease), stroke .45s var(--ease); }
.tri text, .tnode text, .tlit text, .cseg text, .edges text, .legend text {
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
  font-family: Nunito, ui-rounded, system-ui, sans-serif;
}
.tri text { transition: fill .3s; }
.tri.pop { animation: pop .6s var(--spring); }
.tnode { cursor: pointer; }
.tnode circle, .tnode text { transition: fill .35s; }
.tnshape { stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; transition: stroke .4s, fill .4s; }
.tnshape.line { stroke-width: 14; stroke-opacity: .5; }
.tlit { pointer-events: none; }
.trail path { fill: none; stroke-width: 4; stroke-linecap: round; pointer-events: none; }
.trail circle { pointer-events: none; }
.legend text { font-size: 10.5px; font-weight: 800; fill: rgba(241, 237, 224, .55); }

/* chromatic clock */
.cseg path { transition: fill .45s var(--ease); }
.cseg text { transition: fill .3s; }
.cnode { transition: fill .35s; pointer-events: none; }
.cscale { fill: rgba(87, 137, 1, .1); stroke: var(--moss); stroke-width: 1.6; stroke-dasharray: 3 5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.cchord { stroke-width: 3; stroke-linejoin: round; pointer-events: none; transition: stroke .4s, fill .4s; }
.edges circle { fill: var(--bg); stroke: rgba(241, 237, 224, .25); stroke-width: 1; }
.edges text { font-size: 10px; font-weight: 900; fill: var(--tx); }
#wheel {
  width: min(100%, 41dvh, 420px);
  aspect-ratio: 1;
  touch-action: none;
  overflow: visible;
  cursor: grab;
  transition: width .7s var(--spring);
}
#wheel:active { cursor: grabbing; }
.stage[data-view="tonnetz"] #wheel {
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}
.app:not([data-mode="explore"]) #wheel { width: min(100%, 33dvh, 370px); }
.seg { transform-box: fill-box; transform-origin: center; cursor: pointer; }
.seg path { transition: fill .5s var(--ease); }
.seg.pop { animation: pop .6s var(--spring); }
@keyframes pop { 0% { transform: scale(.9); } 45% { transform: scale(1.08); } 100% { transform: scale(1); } }
.lbl text, .dotg text, .center text {
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-family: Nunito, ui-rounded, system-ui, sans-serif;
}
.seg text { transition: fill .35s; }
.dc { transform-box: fill-box; transform-origin: center; transition: transform .5s var(--spring); }
.dc circle, .dc text { transition: fill .35s; }
.dc.on { transform: scale(1.32); }
.blob { stroke-width: 2.5; stroke-linejoin: round; pointer-events: none; transition: fill .45s, stroke .45s; }
.frame { fill: none; stroke: rgba(241, 237, 224, .42); stroke-width: 1.6; stroke-dasharray: 2 5; stroke-linecap: round; pointer-events: none; }
.rip {
  fill: none;
  stroke-width: 2.4;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: rip 1.3s cubic-bezier(.15, .7, .3, 1) both;
}
@keyframes rip { 0% { transform: scale(.35); opacity: .95; } 100% { transform: scale(3.4); opacity: 0; } }
.rip.big { stroke-width: 2; animation: ripbig 1.6s cubic-bezier(.15, .7, .3, 1) both; }
@keyframes ripbig { 0% { transform: scale(.92); opacity: .7; } 100% { transform: scale(2.12); opacity: 0; } }
.center .cname.pop { animation: cpop .55s var(--spring); transform-box: fill-box; transform-origin: center; }
@keyframes cpop { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- piano ---------- */
.piano { position: relative; height: 58px; margin: 8px 16px 0; flex: 0 0 auto; touch-action: none; }
.k {
  position: absolute;
  top: 0;
  cursor: pointer;
  transition: background .3s, transform .35s var(--spring), box-shadow .35s;
}
.k.w { height: 100%; background: #DDD6C3; border-radius: 5px 5px 14px 14px; z-index: 1; box-shadow: inset 0 -4px 0 rgba(74, 64, 46, .25); }
.k.b { height: 60%; background: var(--khaki); border-radius: 4px 4px 10px 10px; z-index: 2; box-shadow: 0 3px 0 var(--bg), inset 0 -3px 0 rgba(0, 0, 0, .25); }
.k i { position: absolute; left: 50%; bottom: 8px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; transition: background .3s, transform .4s var(--spring); }
.k.b i { bottom: 6px; }
.k.sc.w i { background: var(--moss); }
.k.sc.b i { background: var(--grass); opacity: .7; }
.k b {
  position: absolute; left: 0; right: 0; bottom: 15px;
  text-align: center; font-size: 9px; font-weight: 900;
  opacity: 0; transform: translateY(4px);
  transition: opacity .25s, transform .4s var(--spring);
}
.k.down { background: var(--c); transform: translateY(3px); box-shadow: 0 8px 20px -6px var(--c); }
.k.down i { background: var(--ink); transform: scale(1.3); }
.k.down b { opacity: 1; transform: none; color: var(--ink); }
.k.bass:not(.down) { box-shadow: inset 0 -6px 0 var(--c); }
.k.bass.b:not(.down) { box-shadow: 0 3px 0 var(--bg), inset 0 -5px 0 var(--c); }
.k.tap { background: var(--tx); }
.k.b.tap { background: var(--s3); }

/* ---------- panels ---------- */
.panels { position: relative; flex: 1; min-height: 0; margin-top: 12px; }
.panel {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 16px 16px;
  opacity: 0;
  transform: translateX(36px) scale(.98);
  pointer-events: none;
  scrollbar-width: none;
  transition: opacity .4s var(--ease), transform .55s var(--ease);
}
.panel::-webkit-scrollbar { display: none; }
.panel.left { transform: translateX(-36px) scale(.98); }
.panel.on { opacity: 1; transform: none; pointer-events: auto; }
.panel:not(.on) *, .panel:not(.on) *::after { animation-play-state: paused !important; }

/* wave: the water surface the bubbles float on */
.wv { display: block; width: calc(100% + 32px); height: 34px; margin: -16px -16px 0; position: relative; z-index: 0; pointer-events: none; }
.floaty { position: relative; z-index: 1; }

/* ---------- bubbles ---------- */
.bub {
  --amp: 0;
  position: relative;
  overflow: hidden;
  border-radius: var(--br, var(--pebble));
  will-change: transform, translate;
  background: radial-gradient(120% 80% at 50% 28%, color-mix(in srgb, var(--c) 22%, var(--s1)), var(--s1) 78%);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 28%, transparent);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 9px;
  gap: 0;
  transition: --amp .9s ease, transform .45s var(--spring), box-shadow .4s, background .4s;
}
.bub:active { transform: scale(.88); }
.bub .num { position: relative; font-size: 11px; font-weight: 900; color: var(--c); text-shadow: 0 1px 6px var(--bg); }
.bub .nm { position: relative; font-size: 15px; font-weight: 900; letter-spacing: -.02em; color: var(--tx); text-shadow: 0 1px 8px var(--bg); line-height: 1.1; }
.bub.on { box-shadow: inset 0 0 0 2px var(--c); }
.bub.live {
  --amp: 1;
  transition: --amp .18s ease, transform .45s var(--spring), box-shadow .3s, background .3s;
  background: radial-gradient(120% 80% at 50% 28%, color-mix(in srgb, var(--c) 34%, var(--s1)), var(--s1) 85%);
  box-shadow: inset 0 0 0 2px var(--c), 0 10px 30px -10px var(--c);
}
.bub.sug::before {
  content: '';
  position: absolute; top: 7px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 10px var(--c);
  animation: dotpulse 1.4s ease-in-out infinite;
  z-index: 2;
}
@keyframes dotpulse { 50% { transform: scale(1.7); opacity: .5; } }

.viz {
  position: absolute;
  left: 50%; top: 40%;
  width: min(118%, 66px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(calc(.94 + .12 * var(--amp)));
  opacity: calc(.36 + .64 * var(--amp));
  pointer-events: none;
  overflow: visible;
}
.viz * { transform-box: fill-box; transform-origin: center; }
.viz path, .viz ellipse, .viz circle { fill: var(--c); }

/* Tonic — a slowly turning flower; when it sounds, a deep resonant pulse with rings */
.viz .spin { animation: spin 26s linear infinite; }
.viz .spin.rev { animation-direction: reverse; }
.viz .spin.slow { animation-duration: 38s; }
.viz .spin ellipse { fill-opacity: .55; }
.viz .res { animation: resonate 1.05s cubic-bezier(.2, .8, .3, 1) infinite; }
.viz .rings circle { fill: none; stroke: var(--c); stroke-width: 2; animation: ring 1.6s ease-out infinite; }
.viz .rings circle:nth-child(2) { animation-delay: .53s; }
.viz .rings circle:nth-child(3) { animation-delay: 1.06s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes resonate {
  0%   { transform: scale(calc(1 - .1 * var(--amp))); }
  18%  { transform: scale(calc(1 + .24 * var(--amp))); }
  100% { transform: scale(1); }
}
@keyframes ring { 0% { transform: scale(1); opacity: calc(.9 * var(--amp)); } 100% { transform: scale(3.1); opacity: 0; } }

/* Subdominant — leaves swaying in a breeze; when it sounds they unfurl and shed pollen */
.viz .sway { transform-origin: 50% 100%; animation: sway 5s ease-in-out infinite alternate; }
.viz .flut { transform-origin: 50% 100%; animation: flutter .75s ease-in-out infinite alternate; }
.viz .grow { transform-origin: 50% 100%; animation: grow 1.5s ease-in-out infinite; }
.viz .grow path { fill-opacity: .6; }
.viz .pollen circle { animation: pollen 1.5s ease-out infinite; opacity: 0; }
.viz .pollen circle:nth-child(2) { animation-delay: .5s; }
.viz .pollen circle:nth-child(3) { animation-delay: 1s; }
@keyframes sway { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes flutter { from { transform: rotate(calc(-13deg * var(--amp))); } to { transform: rotate(calc(13deg * var(--amp))); } }
@keyframes grow { 0%, 100% { transform: scale(calc(1 + .03 * var(--amp))); } 50% { transform: scale(calc(1 + .2 * var(--amp))); } }
@keyframes pollen { 0% { transform: translateY(0); opacity: var(--amp); } 100% { transform: translateY(-34px) scale(.4); opacity: 0; } }

/* Dominant — a bud ringed by seeds; when it sounds it trembles and the ring tightens */
.viz .orb { animation: spin 18s linear infinite; }
.viz .orb2 { animation: tighten .7s ease-in-out infinite; }
.viz .tense { animation: tense 3.2s ease-in-out infinite; }
.viz .trem { animation: tremble .13s linear infinite; }
.viz .eye { fill: var(--bg) !important; }
@keyframes tighten {
  0%, 100% { transform: rotate(calc(-22deg * var(--amp))) scale(1); }
  50% { transform: rotate(calc(22deg * var(--amp))) scale(calc(1 - .24 * var(--amp))); }
}
@keyframes tense { 0%, 100% { transform: scale(.96); } 50% { transform: scale(1.05); } }
@keyframes tremble {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(calc(1.8px * var(--amp)), calc(-1.2px * var(--amp))); }
  50% { transform: translate(calc(-1.5px * var(--amp)), calc(1.4px * var(--amp))); }
  75% { transform: translate(calc(1.1px * var(--amp)), calc(1.6px * var(--amp))); }
}

/* Outside the key — a drifting droplet */
.viz .bobv { animation: bobv 3.6s ease-in-out infinite; }
@keyframes bobv { 50% { transform: translateY(-4px) rotate(6deg); } }

/* ---------- explore ---------- */
.chords { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 5px; }
.chords .bub { height: 76px; }
.card {
  background: var(--s1);
  border-radius: 30px 26px 32px 24px;
  padding: 14px 16px;
  margin: 8px 0 10px;
}
.card-top { display: flex; gap: 12px; align-items: center; }
.badge {
  min-width: 48px; height: 48px; padding: 0 8px;
  border-radius: var(--pebble);
  display: grid; place-items: center;
  font-weight: 900; font-size: 17px;
  background: var(--c, var(--mint)); color: var(--ink, var(--bg));
  transition: background .4s, color .4s;
}
.card h2 { font-size: 21px; font-weight: 900; letter-spacing: -.01em; }
.tag { font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--c, var(--mint)); margin-top: 1px; }
.card p { font-size: 14.5px; line-height: 1.45; color: rgba(241, 237, 224, .76); margin-top: 10px; font-weight: 600; }
.notes { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.note { padding: 6px 12px; border-radius: 999px; background: var(--s2); font-size: 13px; font-weight: 800; }
.note.root { background: var(--c); color: var(--ink); }
.swap { animation: swap .55s var(--ease); }
@keyframes swap { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.hint { font-size: 12.5px; font-weight: 600; color: var(--mut); text-align: center; margin-top: 14px; }
.desc { font-size: 14px; font-weight: 600; line-height: 1.45; color: rgba(241, 237, 224, .74); margin: 8px 2px 10px; min-height: 2.9em; }

/* ---------- progressions ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 42px; padding: 0 17px;
  border-radius: 24px 20px 24px 18px;
  background: var(--s1);
  font-weight: 800; font-size: 14px;
  transition: background .3s, color .3s, transform .4s var(--spring);
}
.chip:active { transform: scale(.9); }
.chip.on { background: var(--tx); color: var(--bg); }
.steps { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 6px; }
.steps .bub { height: 74px; }
.steps .bub.enter { animation: enter .6s var(--spring) backwards; animation-delay: var(--ed, 0s); }
@keyframes enter { from { transform: scale(.2) translateY(24px); opacity: 0; } }

/* ---------- compose ---------- */
.row-label { display: flex; justify-content: space-between; font-size: 10px; font-weight: 900; letter-spacing: .16em; color: var(--mut); margin: 0 2px 4px; }
.seq { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 6px 16px 4px; scrollbar-width: none; min-height: 80px; }
.seq::-webkit-scrollbar { display: none; }
.seq .bub { flex: 0 0 54px; height: 70px; }
.seq .bub { transform: translateX(var(--dx, 0px)); }
.seq.dragging .bub { transition: transform .3s var(--spring), box-shadow .3s; }
.seq .bub.lifted {
  z-index: 3;
  transform: translateX(var(--dx, 0px)) translateY(-6px) scale(1.12);
  transition: box-shadow .3s, background .3s;
  box-shadow: inset 0 0 0 2px var(--c), 0 16px 30px -10px var(--c);
  cursor: grabbing;
}
.seq .bub { -webkit-touch-callout: none; }
.seq .bub.enter { animation: enter .6s var(--spring); }
.seq .bub.sel { box-shadow: inset 0 0 0 2px var(--tx); }
.seq .bub.sel::after {
  content: '×';
  position: absolute; top: 4px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--tx); color: var(--bg);
  font-size: 14px; font-weight: 900; line-height: 18px; text-align: center;
  z-index: 2;
  animation: enter .4s var(--spring);
}
.slot {
  flex: 0 0 54px; height: 70px;
  border-radius: var(--pebble);
  border: 1.5px dashed rgba(241, 237, 224, .2);
  display: grid; place-items: center;
  color: var(--mut); font-size: 22px;
}

/* mood of the move just made */
.moodnow { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 7px; margin: 8px 2px 8px; min-height: 22px; font-weight: 700; }
.mn-path { font-size: 12px; font-weight: 900; letter-spacing: .04em; color: var(--mut); }
.mn-mood { font-size: 16px; font-weight: 900; color: var(--c, var(--tx)); }
.mn-lead { font-size: 15px; font-weight: 900; }
.mn-feel { font-size: 13px; color: rgba(241, 237, 224, .66); font-weight: 600; }

/* suggested next moves, each with a feeling */
.moods { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 10px; padding: 2px 16px 4px; scrollbar-width: none; }
.moods::-webkit-scrollbar { display: none; }
.moodcard {
  flex: 0 0 152px;
  min-height: 84px;
  padding: 10px 13px 11px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  text-align: left;
  border-radius: 26px 20px 28px 18px;
  background: radial-gradient(130% 120% at 0% 0%, color-mix(in srgb, var(--c) 24%, var(--s1)), var(--s1) 70%);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 34%, transparent);
  animation: enter .55s var(--spring) backwards;
  transition: transform .4s var(--spring), box-shadow .3s;
}
.moodcard:active { transform: scale(.93); box-shadow: inset 0 0 0 2px var(--c), 0 10px 26px -10px var(--c); }
.mc-top { display: flex; align-items: baseline; gap: 6px; width: 100%; }
.mc-top b { font-size: 17px; font-weight: 900; color: var(--tx); }
.mc-top em { font-style: normal; font-size: 11px; font-weight: 900; color: var(--c); }
.mc-top::after { content: '+'; margin-left: auto; font-size: 17px; font-weight: 800; color: var(--c); line-height: 1; }
.mc-mood { font-size: 14px; font-weight: 900; color: var(--c); margin-top: 2px; }
.mc-feel { font-size: 11.5px; font-weight: 600; line-height: 1.3; color: rgba(241, 237, 224, .68); }

/* ---------- sound: playing style + colour ---------- */
.soundbar { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.stylechips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.stylechips::-webkit-scrollbar { display: none; }
.stylechips button {
  flex: 0 0 auto; height: 40px; padding: 0 15px;
  border-radius: 22px 18px 22px 16px;
  background: var(--s1);
  font-size: 13.5px; font-weight: 900;
  color: var(--mut);
  transition: background .3s, color .3s, transform .4s var(--spring);
}
.stylechips button:active { transform: scale(.9); }
.stylechips button.on { background: var(--grass); color: var(--bg); }
.colourpick {
  display: grid; grid-template-columns: auto 1fr 1fr 1fr; align-items: center; gap: 4px;
  padding: 4px 4px 4px 14px;
  border-radius: 24px 20px 24px 18px;
  background: var(--s1);
}
.cpl { font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); margin-right: 6px; }
.colourpick button {
  height: 36px; border-radius: 18px 14px 18px 12px;
  font-size: 13.5px; font-weight: 900; color: var(--mut);
  transition: background .35s, color .35s, transform .4s var(--spring);
}
.colourpick button:active { transform: scale(.9); }
.colourpick button.on { color: var(--bg); background: var(--mint); }
.colourpick[data-level="2"] button.on { background: linear-gradient(120deg, var(--mint), var(--grass)); }
.colourpick[data-level="0"] button.on { background: var(--tx); }

/* bubbles: long chord names shrink, flavoured chords get a seed, spice gets a glint */
.bub.long .nm { font-size: 12.5px; letter-spacing: -.03em; }
.steps.dense .bub .nm { font-size: 12px; letter-spacing: -.04em; }
.steps.dense .bub.long .nm { font-size: 10.5px; }
.steps.dense .bub { padding-left: 2px; padding-right: 2px; }
.bub.flavoured::before {
  content: '';
  position: absolute; top: 7px; left: 50%; margin-left: -3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tx); opacity: .8; z-index: 2;
}
.bub.spicy .num::before { content: '✦ '; }

/* spice suggestions */
.mc-top i { font-style: normal; font-size: 9.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--c); opacity: .8; }
.moodcard.spice { background: radial-gradient(130% 120% at 0% 0%, color-mix(in srgb, var(--c) 30%, var(--s2)), var(--s1) 70%); box-shadow: inset 0 0 0 1.5px var(--c); }

/* piano: the top voice and individual notes as they sound */
.k.top.down { box-shadow: 0 8px 22px -4px var(--c), inset 0 0 0 2px rgba(255, 255, 255, .55); }
.k.ping { animation: ping .28s ease-out; }
@keyframes ping { 0% { filter: brightness(1.45); } 100% { filter: none; } }

/* ---------- export ---------- */
.exportbtn {
  width: 100%; height: 48px; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 24px 20px 24px 18px;
  background: var(--s1);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--grass) 30%, transparent);
  color: var(--tx); font-size: 15px; font-weight: 900;
  transition: transform .4s var(--spring), background .2s;
}
.exportbtn svg { color: var(--grass); }
.exportbtn:active { transform: scale(.95); background: var(--s3); }
#export { --c: var(--grass); }
.sheet-sub { font-size: 13px; font-weight: 800; color: var(--mut); font-variant-numeric: tabular-nums; }
.sheet-chords { font-size: 14px; font-weight: 800; line-height: 1.5; margin-top: 6px; overflow-wrap: anywhere; }
.exactions { display: flex; gap: 8px; margin-top: 16px; }
.exactions .play { flex: 1; }
.exactions [hidden] { display: none; }
.exactions [hidden] + .exsave { flex: 1; }
.exsave {
  flex: 0 0 auto; height: 58px; padding: 0 20px;
  border-radius: 26px 22px 28px 20px;
  background: var(--s1); font-size: 16px; font-weight: 900;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--grass) 35%, transparent);
  transition: transform .4s var(--spring);
}
.exsave:active { transform: scale(.94); }
.exstatus { min-height: 1.4em; margin-top: 8px; font-size: 13px; font-weight: 800; color: var(--grass); overflow-wrap: anywhere; }
#export .hint { text-align: left; margin-top: 4px; }

/* ---------- flavour sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 8, 5, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease);
}
.sheet.open { opacity: 1; pointer-events: auto; }
.sheet-card {
  width: min(480px, 100%);
  max-height: 78%;
  overflow-y: auto;
  padding: 16px 16px 22px;
  border-radius: 34px 28px 0 0;
  background: var(--s2);
  box-shadow: 0 -20px 50px -20px #000, inset 0 1.5px 0 color-mix(in srgb, var(--c) 50%, transparent);
  transform: translateY(40px) scale(.97);
  transition: transform .55s var(--spring);
}
.sheet.open .sheet-card { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h3 { font-size: 20px; font-weight: 900; color: var(--c); }
.sheet-head button { width: 44px; height: 44px; border-radius: 50%; background: var(--s3); font-size: 16px; font-weight: 900; }
.sheet-label { font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); margin: 12px 2px 6px; }
.flopts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.flopts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.flopts button {
  min-height: 56px; padding: 8px 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  text-align: left;
  border-radius: 20px 16px 20px 14px;
  background: var(--s1);
  transition: background .25s, transform .4s var(--spring), box-shadow .25s;
}
.flopts button:active { transform: scale(.94); }
.flopts button b { font-size: 15px; font-weight: 900; }
.flopts button small { font-size: 11.5px; font-weight: 600; color: var(--mut); line-height: 1.25; }
.flopts button.on { background: color-mix(in srgb, var(--c) 22%, var(--s1)); box-shadow: inset 0 0 0 2px var(--c); }
.flopts button.on b { color: var(--c); }

/* ---------- transport ---------- */
.transport { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.play {
  flex: 1; height: 58px;
  border-radius: 30px 24px 30px 22px;
  background: var(--grass); color: var(--bg);
  font-weight: 900; font-size: 17px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 10px 28px -14px var(--grass);
  transition: transform .45s var(--spring), background .35s, color .35s, box-shadow .35s;
}
.play:active { transform: scale(.94); }
.play.on { background: var(--rasp); color: #fff; box-shadow: 0 10px 28px -12px var(--rasp); }
.play svg { width: 18px; height: 18px; }
.sq {
  width: 58px; height: 58px; flex: 0 0 auto;
  border-radius: 26px 22px 28px 20px;
  background: var(--s1);
  display: grid; place-items: center;
  transition: transform .45s var(--spring), background .2s;
}
.sq:active { transform: scale(.85) rotate(-6deg); background: var(--s3); }
.bpm { display: flex; align-items: center; background: var(--s1); border-radius: 26px 22px 28px 20px; height: 58px; flex: 0 0 auto; }
.bpm button { width: 38px; height: 58px; font-size: 20px; font-weight: 800; border-radius: 20px; transition: transform .35s var(--spring); }
.bpm button:active { transform: scale(.75); }
.bpm-val { min-width: 34px; text-align: center; font-weight: 900; font-size: 15px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bpm-val small { display: block; font-size: 8px; letter-spacing: .16em; color: var(--mut); }

/* ---------- tabs ---------- */
.tabs {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 12px 10px;
  background: var(--s1);
  border-radius: 34px 28px 34px 26px;
  padding: 6px; height: 70px;
  flex: 0 0 auto;
}
.ind {
  position: absolute; top: 6px; left: 6px; bottom: 6px;
  width: calc((100% - 12px) / 3);
  border-radius: var(--pebble);
  background: var(--tx);
  transition: transform .6s var(--spring);
}
.tab {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 800;
  color: var(--mut);
  transition: color .35s, transform .4s var(--spring);
}
.tab:active { transform: scale(.88); }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
